ComponentRef createComponent(ComponentFactory componentFactory, [ num index = -1, Injector injector = null, List<List> projectableNodes = null ])

Instantiates a single Component and inserts its Host View into this container at the specified index.

The component is instantiated using its ComponentFactory which can be obtained via ComponentResolver#resolveComponent.

If index is not specified, the new View will be inserted as the last View in the container.

You can optionally specify the Injector that will be used as parent for the Component.

Returns the ComponentRef of the Host View created for the newly instantiated Component.

Source

ComponentRef createComponent(ComponentFactory componentFactory,
    [num index = -1,
    Injector injector = null,
    List<List<dynamic>> projectableNodes = null]) {
  var contextInjector =
      injector != null ? injector : this._element.parentInjector;
  var componentRef =
      componentFactory.create(contextInjector, projectableNodes);
  this.insert(componentRef.hostView, index);
  return componentRef;
}