Setting up basic routing
Specify base href in index.html:
<base href='/'>Add a <base> tag in the <head> section of index.html as below:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Momentz4ever</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>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