The factory, directive, constant, value and filter etc. methods are registered with modules and we can see the way of presenting to all as below.
You can use dependency injection for services, filters and directives.
You can use dependency injection for services, filters and directives.
var app = angular.module('DIApp', []); // SERVICES. app.service("diService", diService); var diService= function() { this.getCal = function() { return (1+10); } } // FACTORY. app.factory('diFactory', ['diService', function (diService) { // TODO: YOU CUSTOM LOGIC. var result = diService.getCal(); }]); //DIRECTIVE. app.directive('diDirective', ['diService', function(diService) { // TODO: YOU CUSTOM LOGIC. var result = diService.getCal(); }]) //FILTER. app.filter('filterName', ['depService', function(depService) { // TODO: YOU CUSTOM LOGIC. var result = diService.getCal(); }]); //VALUE app.value("value", 'Anil Singh'); //CONSTANT app.constant("constant", 'constant value.');
Blogger Comment
Facebook Comment