我有以下两条指令。当我们点击从issuedesc创建按钮ng-click在AngularJS中不起作用
<body>
<issuedesc></issuedesc>
</body>
在浏览器中,上述工程 - 第一个(recentisls)创建第二个 'issuedesc'
directive('recentisls', function ($compile) {
return {
restrict: 'E',
transclude: true,
scope: {},
controller: function ($scope, $element) {
$scope.showIsDsc = function() {
var el = $compile("<issuedesc></issuedesc>")($scope);
$('body').html(el);
},
template: '<div ng-click="showIsDsc()"></div>',
};
}).
directive('issuedesc', function ($compile) {
return {
restrict: 'E',
transclude: true,
scope: {},
controller: function ($scope, $element) {
$scope.addcomts = function() {
alert("A Hello");
};
},
template: '<input ng-click="addcomts()" type="button" value="Submit Comments"/>,
replace: true
};
})
HTML代码。
但是,
<body>
<recentisls></recentisls>
</body>
在浏览器中,上述当我们点击从recentisls创建的按钮不起作用。
此代码对我的作品 - VAR EL = $( “ ”).appendTo ('身体'); $ compile(el)($ scope) –
shashankt