I saw the following question (among other similar questions) and solves the problem of trying to insert a factory into a directory link function:
Engineering into the Directive
The solutions I saw support the link function as part of the directive:
angular.module('myapp')
.directive('myDir', function(myService){
return {
restrict: 'E',
scope: {
frame: '='
},
link: function postLinkFn(scope, elem, attr) {
myService.doSomething();
}
};
});
However, I want to be able to share postLinkFn outside of the .directive scope for the organization, just as I can do with controllers.
Is it possible to separate this function, as well as introduce a service into it?
source
share