Angular2: Two-way data binding on component dynamically inserted using DynamicComponentLoader

前端 未结 2 1904
暖寄归人
暖寄归人 2021-02-19 10:17

I am developing an Angular2 app, and I faced a problem:

I have a set of different objects that can be selected using UI. Each of this objects has a set of options (diffe

2条回答
  •  不要未来只要你来
    2021-02-19 10:18

    Here is what you can do, move your code from constructor to ngOnInit and use promises for assigning dynamic value.

    ngOnInit(){
        this.dynamicComponentLoader.loadIntoLocation(DynamicComponent, this.elementRef,'container').then((component)=>{
            component.instance.currentSelection = currentSelection;
        });
    }
    

提交回复
热议问题