Defining Child Routes

In the last post How organize your folders in Angular we learned how to organize your folders for professional projects in angular, the next step usually managing the routes, usually, I add this responsibility to Angular Cli but, when I need a better organization, I need write my own file  "app-routing. module" and I will need to implement child routes.

The child routes are identified with the label “children" and they are objects to any main route. We have the next routes in the file  "app-routing-module":


We will need to manage one template for the dashboard and another for the login and register; the first step is to create a new component called pages:



The path:’  ’ empty work with the routes into the children array, and the other routes work with other types for styles and templates.

We add some content to the main page of the component page:

Run the project and check the result in the browser:

It is the result for the default route, you have a static template with the title “Main page Admin”, and dynamic content for the label “router outlet”, but when you change the url you obtain a new result without a static template. 



This is the link for the repository: basicAngular,  the commit for this session is:  

 6f0dae8fb8556c0039ef34c66167b7a7d7a98e8e, that's all for now, thank you for reading bye!



Comments

Popular posts from this blog

FILE SERVER

Kubernates configMaps and Volumes

Kubernates Intro