Skip to main content

Posts

Showing posts with the label Services vs Factory vs Provider angular

How to inject to services, factories and providers?

Hello everyone, today I am going to share the very interesting when we play with services, factory and provider in angular. I notice an interesting point when I playing with providers . Here highlight the visibility of injectable. The services, factory  and provider are injectable but  the injectable is different for provider than from services  and factory. I am going to a scenario, if you declare a constant(i.e. like angular.constant( 'baseUrl' , 'http://localhost:9669/' )), here you can inject into services, factories and providers. But when you declare a value (i.e. like angular.value( 'user' , {id: 'uid9669'} )), here you can inject into services and factories but not provider.  The provider creating a $get function and then you can  inject it. live demo click on link  http://embed.plnkr.co/0EANoZ/preview For example over the injecting as given below. AngularJs code sample var app = angular.module( 'userApp' ...