angular 动态输入html 标签 nglick不能用的处理方法

来源:互联网 发布:淘宝哪家的玉是真的 编辑:程序博客网 时间:2024/06/16 02:17
var mainCtrl = angular.module("myApp.main", []);
mainCtrl    .directive('compileHtml', function ($compile) {        return {            restrict: 'A',            replace: true,            link: function (scope, ele, attrs) {                scope.$watch(function () {                        return scope.$eval(attrs.ngBindHtml);                    },                    function (html) {                        ele.html(html);                        $compile(ele.contents())(scope);                    });            }        };    });
-----------------------------------------------------------
// var html = '<span  ng-click="openUrl()">哈哈啊</span>ad as as a ';// $scope.test = html;// $scope.openUrl = function () {//     alert("弹出");// };

<div class="footer-send" ng-bind="sendBtn"  compileHtml="sendBtn"></div>