How to use dependency injection (di) correctly in angular 2?
Answer / Amita Sharma
To use DI correctly in Angular 2, you need to create a service, mark it with @Injectable(), and then inject it into your components using the constructor. You should only inject services that are required by the component, and avoid creating new instances directly.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is service heroservice?
What ide's are currently used for the development of angularjs?
What is bazel and closure compiler in angular6?
What is model in angular?
What is the use of a double-click event in angularjs?
What is afterviewinit?
What is ng template in angular?
What are the Pipes?
How many modules can be used in a single html page?
What would be a good use for ngzone service?
What do you mean by module?
What are static and public in angular?