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(1);
iElement.on('click',scope.addBook);
}
}
})
.controller('firstController',['$scope',function ($scope) {
console.log($scope);
}]);