March 2017
Intermediate to advanced
821 pages
18h 21m
English
A provider tells Angular 2 how to create an instance of a service while injecting it. A provider is set using the providers or viewProviders properties of a component.
Let's look at an example of how to create providers. Place this code above the App component's code:
var Service1 = ng.core.Class({ constructor: function() { }, getValue: function() { return "xyz" } }); var Service2 = ng.core.Class({ constructor: function() { }, getValue: function() { return "def" } }); var Service3 = ng.core.Class({ constructor: function() { }, getValue: function() { return "mno" } }); var Service4 = ng.core.Class({ constructor: [Service2, Service3, function(s2, s3) { console.log(s2); console.log(s3); }], getValue: function() { return "abc" ...Read now
Unlock full access