One of the important advantages of NgModules is that they can be lazy loaded. It can also import other modules that are needed in the current module. ![]() ![]() NgModules consist of files and code related to a specific domain or that have a similar set of functionalities.Ī typical NgModule file declares components, directives, pipes, and services. Angular Material, which is a third party tool, is also a type of NgModule. What are NgModules?Īngular libraries like RouterModule, BrowserModule, and FormsModule are NgModules. Lazy loading allows Angular to load components and modules as and when they're needed.įirst of all, to understand how lazy loading works in Angular, we need to understand the basic building blocks of the framework: NgModules. But as the application grows the load time will increase if everything is loaded at once. This means that a lot of unnecessary libraries or modules might be loaded as well.įor a small application this would be okay. ![]() Since Angular creates a SPA (Single Page Application), all of its components are loaded at once. Lazy loading is the process of loading components, modules, or other assets of a website as they're required.
0 Comments
Leave a Reply. |