I'm trying to create an angular directive for calling service method to check changing database.
Here is my HTML:
<div my-directive="Panel.check"></div>
What I'm want:
Call "check" method of "Panel" service. Directive don't know anything about services and its method. It just parses attributes and binds them, Or if must be injected show me the solution.
What I have:
appDirectives.directive('myDirective', function($parse) {
var directiveOnObject = {
restrict: 'A',
scope: { method:'&myDirective' },
link: function(scope,element,attrs) {
var panel = scope.method;
console.log(panel());
}
};
return directiveOnObject;
});
Scope method should get instance of "Panel" and call "check" method of it.
Is there any solution to this? Please explain.