我正在制定自定义指令并在指令中设置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的范围?