Setting up basic routing
Specify base href in index.html:
Add a <base>
tag in the <head>
section of index.html as below:
Setting up Basic Routes Array:
Above, we imported Route
and RouterModule
from @angular\router
.
Next, we set a const ROUTES of type Route[]
, an array of type Route
Note the setting up of children
routes for the path albums/:id
.
Finally, in the AppModule's metadata in @NgModule
decorator, we specify below inside imports
array:
<router-outlet>
<router-outlet>
Based on the current route in the browser, Angular would display the contents of the component as per routes-component configuration above, inside the <router-outlet></router-outlet>
tags.
`
Last updated