标签:
require
引用其他controller
var app = angular.modeule(‘myapp‘,[]); app.directive(‘common‘,function(){ return { ... controller: function($scope){ this.method1 = function(){ }; this.method2 = function(){ }; }, ... } }); app.directive(‘d1‘,function(){ return { ... require: ‘?^common‘, link: function(scope,elem,attrs,common){ scope.method1 = common.method1; .. }, ... } }); app.directive(‘d2‘,function(){ return { ... require: ‘?^common‘, link: function(scope,elem,attrs,common){ scope.method1 = common.method1; .. }, ... } });
标签:
原文地址:http://www.cnblogs.com/yfann/p/4594307.html