The Angular CLI is a command line interface tool that can create a project, add files, and perform a variety of ongoing development tasks such as testing, bundling, and deployment.
If you need to update Angular CLI you can update easily by reinstalling it.
npm install -g @angular/cli
ng new PROJECT-NAME cd PROJECT-NAME ng serve --open
ng new is used to generate angular boilerplate.
To implement the Lazy Loading in Angular we need to create a routing module and a module for that component Like in below image.
In above image have you seen posts-routing.module.ts and posts.module.ts
Now let's see what we need to code.
On 14 line we need to specify as a RouterModule.forChild instead of root.
Now let's look into posts.module.ts
That's it we are done with child level.
Now we need to create a file app-routing.module.ts on root level it means inside the app folder.
Like how we create a routing in angular.
In app.module.ts we need to remove the declarations for the components which we would like to lazy load. Like we already declared the posts component inside the posts.module.ts
This is our final output
originally published at reactgo.com