In this video we will discuss generating services using the Angular CLI. Generating services is similar to generating components.
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
/ @aarvikitchen5572
To generate a component we use
ng generate component componentName or ng g c componentName
Similarly to generate a service we use
ng generate service serviceName or ng g s serviceName
For example. to generate a customer service we use the following command.
ng generate service customer
The above command generates the service and the spec file. What it does not do is register the service. Remember for us to be able to use the service, we must register the service.
We can do it manually after creating the service or we can tell Angular CLI to register our service with a module, using --module option. We can also use it's alias -m
The following command not only generates employee service, it also registers our service witht the AppModule
ng generate service employee -module=app.module
The above command can also be rewritten using aliases
ng g s employee -m=app.module
We can also use the --dry-run flag or it's alias -d to see what Angular CLI generates. Notice in the following command we are using -d option, so Angular CLI simply report the files it is going to generate
ng g s student -d
The above command generates the service and the spec file. If you do not want the spec file, simply set --spec=false
ng g s student -d --spec=false
When generating a component, Angular CLI by default creates a folder for the component and places all the component files in that folder. A service on the other hand will not have it's own folder. If you want a folder of it's own for a service that the Angular CLI is generating, set --flat option to false as shown below.
ng g s student -d --spec=false --flat=false
Text version of the video
http://csharp-video-tutorials.blogspo...
Slides
http://csharp-video-tutorials.blogspo...
Angular CLI Tutorial
• What is Angular CLI
Angular CLI Text articles & Slides
http://csharp-video-tutorials.blogspo...
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...
All Dot Net and SQL Server Tutorials in Arabic
/ kudvenkatarabic
Auf dieser Seite können Sie das Online-Video Angular cli generate service mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer kudvenkat 11 Oktober 2017 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 35,843 Mal angesehen und es wurde von 168 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!