即使在使用$ compile之后也无法触发click事件

时间:2015-11-02 11:50:21

标签: angularjs

//Directive for adding buttons on click that show an alert on click
app.directive("addbuttons", function($compile){
    return function(scope, element, attrs){
        element.bind("click", function(){

            angular.element(document.getElementById('stopList')).append($compile("<md-list-item  class='md-3-line'  style='background:rgb(233, 233, 233);margin:10px;padding-left: 10px;position: relative;min-height: 60px;'><div class='md-list-item-text'><h3>"+scope.name+"</h3><h4>"+scope.noOfStudents+"</h4></div><div ng-click='showConfirm($event)' class='delete_icon'></div></md-list-item>")(scope));
        });
    };
});

在上面的代码中我写了ng-click =&#39; showConfirm($ event)&#39;在div中,但在将其添加到DOM后会被解雇。

0 个答案:

没有答案