InterviewSolution
Saved Bookmarks
| 1. |
What is the factory method in Angular 2? |
|
Answer» As services are reusable singleton objects in AngularJS which is USED to organize and share CODES across the APPLICATION, they can be injected into filters, controllers, and directives. Angular 2 offers three ways to create a service; factory, service, and provider. The factory function allows developers to include some logic before creating the object and RETURNS the created object. The syntax for factory function is as follows. app.factory('serviceName',function(){ return serviceObj;}) |
|