标签:book repeat replace fun attr tco add turn lis
angular.module(‘myApp‘,[]) .directive(‘bookList‘,function () { return{ restrict:‘ECAM‘, controller:function ($scope) { console.log($scope); $scope.books=[ { name:‘php‘ }, { name:‘javascript‘ }, { name:‘java‘ } ]; $scope.addBook=function () { alert(‘e‘); } }, controllerAs:‘bookListController‘, template:‘<ul><li ng-repeat="book in books">{{book.name}}</li></ul>‘, replace:true, link: function(scope,iElement,iAttrs,bookListController) { console.log(scope); iElement.on(‘click‘,scope.addBook); } } }) .controller(‘firstController‘,[‘$scope‘,function ($scope) { console.log($scope,1); }]);
标签:book repeat replace fun attr tco add turn lis
原文地址:http://www.cnblogs.com/zhuj/p/7687980.html