Updating Angular and Creating Application Routes
In this tutorial, we’ll cover two topics: first, how to update Angular, and then how to create app routes.
To update Angular, run the command ng update <angular package name>. To find out the package name and check for available updates, first run ng update and press Enter. This will display a list of packages with new versions along with the full update command. It’s important to note that ng update only updates Angular packages — for example, it won’t update a package like Bootstrap.
The second part of the video focuses on creating routes. Routes allow an SPA to behave like a multi-page application. You can create routes either “eagerly” or using lazy loading. Lazy-loaded routes are an important technique for optimizing application performance: the component associated with the route is loaded only when the route is activated, rather than immediately when the application starts.
app.routes
import { Routes } from '@angular/router';
export const routes: Routes = [
{
path: 'users',
loadComponent: () => import('./users/users').then(c => c.Users)
}
];
0 Comments