In this article, I am going to explain how to check the flow of lazy loading in an Angular application using the Augury Google Chrome extension. When I was implementing lazy loading in my project, I faced some difficulty checking which module was lazy-loaded. I came to know about Augury extension, which shows the flow of lazy loading of all modules with a diagram. By seeing visually that our work is half done, if any modules are left behind in code, then we can easily check their routing in the route tree of Augury.
You can install Augury from the Chrome Web Store.
For Windows and Linux, use Ctrl + Shift + I.
For Mac OS X, use Cmd + Opt + I.
You may also like:
Real-World Angular Series, Part 8a: Lazy Loading, Production Deployment, SSL.
Steps to Install Angular
- Basic knowledge of Angular.
- Visual Studio Code must be installed.
- Angular CLI must be installed.
- Node.js must be installed.
Let’s create an Angular project using the following npm command:
First, open this project in VS Code and install Bootstrap by using the following command.
Now, open the styles.css file and add the Bootstrap file reference. To add a reference in the styles.css file, add this line:
Now, create two modules named,
Now, create some demo components in the company module by using the following command:
Now, open the companies-routing.module.ts file and add the following code:
Now, create some demo components in the Product module by using the following commands:
Now, open Product-routing.module.ts file and add the following code inside this file:
Now, add a new component,
Home and open the home.component.html file. Add the following code in this file:
Now, add the following code in the home.component.ts file:
After that, open the app-routing.module.ts file and add the following code:
Now, open app.module.ts file and add the following code:
Open the app.component.html file and add the following code:
Now, run the project by using the
ng serve command in VS Code
Then, run this project with
ng serve -o to compile the code, open your Chrome browser, and test lazy loading.
If you want to check how lazy loading works and how lazy loading routing flow, then Augury is the best tool we have.
Click on ctrl+F12 to enable the debugger and click on the Augury tab.
Click on the router tree. Here, it will show the route flow of our modules. If your project has implemented lazy loading then it will be represented in square brackets.
Now, click on their child components to load the child route after clicking on all child components. This will be shown like in the below image:
The first view that is visible is the Component Tree, which shows the loaded components belonging to the application.
This is my small article about the Augury extension. You can check my previous article and give me some feedback which would be very useful for me to improve in the technological field.
“Knowledge increases through sharing”.
In this article, I discussed how to use Augury Extention to check the flow of lazy loading in Angular 8.
Please give your valuable feedback/comments/questions about this article. Let me know if you liked and understood this article and how I can improve it.