This time I will show you how Angular CLI operates routing, and what are the precautions for Angular CLI operating routing. The following is a practical case, let's take a look.
Generate routes for the application.
Create a project first:
ng new my-routing --routing
You can see that two module.
Look at the routing module:
Look at the app module:
AppRoutingModule has been imported.
Look at app.component.html again:
##router-outlet has been written. Very good.Generate two more components below:ng g c dashboard ng g c order
Modify the html again: Run the application: ng serve -o Yeah. No problem.
For the situation where there are multiple modules in an application.
Generate another module, and bring the routing module ( You can first use the -d parameter to view the file to be generated):ng g m admin --routing
ng g c admin ng g c admin/email -m admin ng g c admin/user -m admin
Generate Gurad.
ng g guard xxx
The above is the detailed content of How Angular CLI operates routing. For more information, please follow other related articles on the PHP Chinese website!