如何在自定义指令中使用ng-controller?

时间:2014-01-16 11:04:48

标签: angularjs

我正在制定自定义指令并在指令中设置ng-controller,并希望在该指令中获得ng-controller的范围。

app.directive('customDirective',['$rootScope', function($rootScope) {
       scope: true,
        restrict: 'A',
        terminal: true,
        priority: 1000,
        compile: function (element, attrs) {
              element.attr("ng-controller", mycontroller);
              element.removeAttr("custom-directive"); 
              $rootScope.dir = scope; //want to set the scope of mycontroller
        }

}]);

如何在rootScope.dir中设置mycontroller的范围?

0 个答案:

没有答案