D
D
Dolerum2021-03-03 14:17:33
Angular
Dolerum, 2021-03-03 14:17:33

What is NgModuleRef for?

Hello.
A question. What exactly does NgModuleRef do? I know what is used to dynamically create components. But I didn’t quite understand from its api (there are only vague guesses) what exactly it is needed for and what functions it carries inside angular.
Google didn't help much in this case.
Thank you for your reply.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kovalsky, 2021-03-04
@Dolerum

NgModuleRef is an object representing a module (an instance of NgModule), as written in the documentation:

NgModuleRef - represents an instance of an NgModule created by an NgModuleFactory. Provides access to the NgModule instance and related objects.

In the example from Stepan Suvorov, we take NgModuleRef for AppModule, the main application module, save the component factory resolver bound to it, get the component factory with it, and use this factory to create components

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question