Angular 动态生成html中 ng-click无效

1 bodyApp.controller('customersCtrl', function ($scope, $http, cfpLoadingBar,$compile) {
2 $scope.test = function(){
3     alert('test');
4 }
5 
6 // TODO 动态生成html中 ng-click无效 解决方法 $compile 是传进来的
7 var html = '<a href="javascript:void(0);" ng-click="$scope.test();"></a>'
8 $("body").append($compile(html)($scope));
9 });

 

posted @ 2016-09-26 10:37  cloudshadow  阅读(6162)  评论(0编辑  收藏  举报