Sunday, 3 November 2019

How to generate a new Service?


To generate a service, we use

ng generate service serviceName 
OR 
ng g s serviceName

While creating a service it will not register with app.module.ts file. We can instruct angular CLI to register while creating the service. But below command works with angular 2 and 4 not in latest version of angular CLI.



All the options which are valid for creating a component are applicable for service as well. So, we can use those command with service as well.

No comments:

Post a Comment