prepare method

ComponentRef<Object> prepare(
  1. ComponentFactory<Object> componentFactory
)

Returns the component created by componentFactory, prepared for routing.

If the component is currently active, or reusable, a cached instance will be returned instead of creating a new one.

Implementation

ComponentRef<Object> prepare(ComponentFactory<Object> componentFactory) {
  return _loadedComponents.putIfAbsent(componentFactory, () {
    final componentRef = componentFactory.create(Injector.map({
      RouterOutletToken: RouterOutletToken(),
    }, _viewContainerRef.injector));
    // ignore: deprecated_member_use
    componentRef.changeDetectorRef.detectChanges();
    return componentRef;
  });
}