What is entryComponents in angular ngModule?

By : raj
Source: Stackoverflow.com

I am working on an Ionic app ( 2.0.0-rc0 ) which depends on angular 2 . So the new introduction of ngModules is included. I am adding my app.module.ts. below.

import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';

  declarations: [
  imports: [
  bootstrap: [IonicApp],
  entryComponents: [
  providers: []
export class AppModule {}

What does entryComponents do here? Components are already defined in declarations . So what the need of repeating them ? I am fairly new to angular and ionic.

By : raj


This is for dynamically added components that are added using ViewContainerRef.createComponent(). Adding them to entryComponents tells the offline template compiler to compile them and create factories for them.

The components registered in route configurations are added automatically to entryComponents as well because router-outlet also uses ViewContainerRef.createComponent() to add routed components to the DOM.


Defines the components that should be compiled as well when this component is defined. For each components listed here, Angular will create a ComponentFactory and store it in the ComponentFactoryResolver.

name = q.Attribute("type").Value;

This video can help you solving your question :)
By: admin