Replaced by Compiler

see this 
:https://github.com/Longfld/DynamicalRouter/blob/master/app/MyRouterLink.ts




On Tuesday, August 23, 2016 at 6:26:31 AM UTC+10, David Marginian wrote:
>
> Now that ComponentResolver is deprecated how can we dynamically load a 
> component and:
>
> 1) Insert it based on a dynamic selector string.
> 2) Pass inputs to the component.
>
> My old code looked like this:
>
> componentPromises.push(this._componentResolver.resolveComponent(WidgetContainerComponent).then((factory:
>  ComponentFactory<any>) => {
>   let widgetId: string = this._widgetIdPrefix + 
> dashboardItem.widgetConfig.widgetId;
>   // Dynamically build the selector string.
>   let selectorString: string = "[id=" + widgetId + "]";
>   let componentRef = factory.create(this._injector, null, selectorString);
>   // Manually set the dashboardItem Input so that the WidgetContainer knows 
> how to build itself.
>   componentRef.instance["dashboardItem"] = dashboardItem;
>   componentRef.instance["refreshObservable"] = this.refreshObservable;
>   // Register the component with appRef change detector, this is critical, 
> without it life cycle events, bindings, etc. will not work.
>   (<any>this._appRef)._loadComponent(componentRef);
> }));
>
>
> The ComponentFactoryResolve doesn't appear to support this and the 
> examples I have seen seem to use a static ViewContainerRef (
> http://plnkr.co/edit/P0spNzu8JbQad2aKACsX?p=info).
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to