filmov
tv
Angular CLI generate routing module
Показать описание
In this video we will discuss generating routing module using the Angular CLI.
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.
To make Angular CLI generate a routing module, all you have to do is use --routing option along with the ng new command when generating a new Angular project.
ng new RoutingDemo --routing
In our previous video, we discussed the steps to implement routing in a separate module, and them import that routing module in the application root module AppModule. Here are those steps.
Step 4 : Configure the application routes.
Step 6 : Specify where you want the routed component view template to be displayed using the router-outlet directive
Step 7 : Create a navigation menu and tie the configured routes with the menu using the routerLink directive. Optionally, use the routerLinkActive directive to style the current route that is active, so the user knows the page that he is on, in the application.
Out of the above 7 steps, we only need to implement steps 4 & 7. The rest of the steps are implemented by the Angular CLI out of the box. Just imagine the amount of time we save.
Before we can implement steps 4 & 7. Let's generate the following 3 components.
Component Angular CLI Command
HomeComponent ng g c home
EmployeesComponent ng g c employees
PageNotFoundComponent ng g c pageNotFound
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'employees', component: EmployeesComponent },
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
Finally we need to install and reference Bootstrap, to style the navigation menu. To install bootstrap execute the following npm command. We can execute this command in the command prompt window or in the integrated terminal window in Visual Studio Code.
"styles": [
]
At this point stop the server. Build and run the application again using the following Angular CLI command. Routing should be working as expected.
ng serve --open
Text version of the video
Slides
Angular CLI Tutorial
Angular CLI Text articles & Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
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.
To make Angular CLI generate a routing module, all you have to do is use --routing option along with the ng new command when generating a new Angular project.
ng new RoutingDemo --routing
In our previous video, we discussed the steps to implement routing in a separate module, and them import that routing module in the application root module AppModule. Here are those steps.
Step 4 : Configure the application routes.
Step 6 : Specify where you want the routed component view template to be displayed using the router-outlet directive
Step 7 : Create a navigation menu and tie the configured routes with the menu using the routerLink directive. Optionally, use the routerLinkActive directive to style the current route that is active, so the user knows the page that he is on, in the application.
Out of the above 7 steps, we only need to implement steps 4 & 7. The rest of the steps are implemented by the Angular CLI out of the box. Just imagine the amount of time we save.
Before we can implement steps 4 & 7. Let's generate the following 3 components.
Component Angular CLI Command
HomeComponent ng g c home
EmployeesComponent ng g c employees
PageNotFoundComponent ng g c pageNotFound
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: 'employees', component: EmployeesComponent },
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
Finally we need to install and reference Bootstrap, to style the navigation menu. To install bootstrap execute the following npm command. We can execute this command in the command prompt window or in the integrated terminal window in Visual Studio Code.
"styles": [
]
At this point stop the server. Build and run the application again using the following Angular CLI command. Routing should be working as expected.
ng serve --open
Text version of the video
Slides
Angular CLI Tutorial
Angular CLI Text articles & Slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
Комментарии