AngularJs-指令和控制器互動
阿新 • • 發佈:2019-01-25
var myModule = angular.module('MyController',[]);
myModule.controller('MyCtrl',function($scope){
$scope.loadData = function(){
console.log("載入資料...");
}
})
myModule.controller('MyCtr2',function($scope){
$scope.loadData2 = function(){
console.log("載入資料2...");
}
})
myModule.directive( 'loader',function(){
return{
restrict:'AE',
link:function(scope,element,attr){
element.bind('mouseenter',function(){
// scope.loadData();
// scope.$apply("loadData()");
scope.$apply(attr.loaddatafn);
})
}
}
})