我正在尝试外化指令的链接功能。 我能够但我无法在该函数中访问$ rootScope或$ window
现有什么::
mapModule.directive('map', function ($rootScope,$window) {
return {
templateUrl: resource + 'partials/maps.html',
controller: 'mapController',
link: function (scope, element, attrs, controllers) {
$rootScope.something = something.
$window.something = something
}
};
});
我想要什么
function mapLinkFunction(scope, element, attrs, controllers) {
$rootScope.something = something//$rootScope is undefined
$window.something = something //$window is undefined
};
mapModule.directive('map', function ($rootScope,$window) {
return {
templateUrl: resource + 'partials/maps.html',
controller: 'mapController',
link: mapLinkFunction
};
});
我尝试将它们都注入mapLinkFunction但不起作用