Angular 10 nested routing & Child Routes example

Angular 10 nested routing & Child Routes example

Today, we will discuss with you how to configure nested routing using a Router Module and outlet. now we will create an application and add nested routing and navigation for our applications.

you can easily Add nested Routing & Child Routes to your angular application by using our example. we are creating a Simple Route application. so you can see our angular 10 nested routing & Child Routes example.

Create new angular app

We will create a new angular app using the following command.

when you create your application at that time Angular CLI ask you Would you like to add Angular routing? (y/N). If you enter with y for Yes. then the angular router will be automatically configured.

Create a component in angular

Now we need to create three component such as home, about, and contact. So let’s run the following command to create components.

Create Nested Routes

Now, we will create two nested routes category-create and category-detail.

Update view file in angular

src/app/app.component.html
In this example, we will create a simple navigation menu using bootstrap. we need to routerLink for redirect the different routes and also add router-outlet.

src/app/home/home.component.html

src/app/category/category.component.html

src/app/category/category-create/category-create.component.html

src/app/category/category-detail/category-detail.component.html

Adding Routing to your Angular 10

src/app/app-routing.module.ts

Run Our Angular Application

Now we will run our Angular application using the below command.