1. 程式人生 > >AngularJs-指令和控制器互動

AngularJs-指令和控制器互動

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); }) } } })