AngularJS – Dependency injection in services, factories, filters etc

Yes you can use dependency injection for filters and directives

Ex:

Filter:

app.filter('<filter>', ['$http', function(http){
    return function(data){
    }
}]);

Directive:

app.directive('<directive>', ['$http', function(http){
    return {
        ....
    }
}]);

Service:

app.factory('<service>', ['$http', function(http) {
  var shinyNewServiceInstance;
  return shinyNewServiceInstance;
}]);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)