Organizing application routes
Our application displays the product list along with the product details and the product create components. We need to organize the routing configuration so that different routes activate each component.
In this section, we will add a new route for the product create component. Later, in the Passing parameters to routes section, we will add a separate route for the product details component.
Let’s get started with the product create component:
- Open the
app.routes.tsfile and add the followingimportstatement:import { ProductCreateComponent } from './product-create/product-create.component'; - Add the following route definition object in the
routesvariable:{ path: 'products/new', component: ProductCreateComponent } - Open the
product-list.component.tsfile and remove any references to theProductCreateComponentclass. - Open the
product-list.component.htmlfile...