insertComponent<T extends Object> method
Future<ComponentRef<T> >
insertComponent<T extends Object>(
- ComponentFactory<
T> componentFactory, - ViewContainerRef viewContainer,
- HtmlElement intoDomElement, {
- Injector? injector,
Returns a future that completes with a new instance created by
componentFactory
, once it is inserted intoDomElement
.
Implementation
Future<ComponentRef<T>> insertComponent<T extends Object>(
ComponentFactory<T> componentFactory,
ViewContainerRef viewContainer,
HtmlElement intoDomElement,
{Injector? injector}) async {
final ref = _componentLoader.loadNextToLocation<T>(
componentFactory, viewContainer,
injector: injector ?? viewContainer.parentInjector);
await _domService.onWrite();
intoDomElement.append(ref.location);
return ref;
}