Angular 插值绑定不';行不通
我正在通过loadAsRoot动态加载组件 加载组件后,该组件将加载到UI中,但即使其属性具有值,也不会加载有界插值数据Angular 插值绑定不';行不通,angular,Angular,我正在通过loadAsRoot动态加载组件 加载组件后,该组件将加载到UI中,但即使其属性具有值,也不会加载有界插值数据 var componentLoadPromise = this._componentLoader.loadAsRoot(MyComponent, "#placeholder", this._injector); return componentLoadPromise.then(myComp=> { return new Promise<bo
var componentLoadPromise = this._componentLoader.loadAsRoot(MyComponent, "#placeholder", this._injector);
return componentLoadPromise.then(myComp=> {
return new Promise<boolean>(resolve =>{
myComp["_hostElement"]["component"]["display"](compOptions, resolve);
});
});
enter code here
DynamicComponentLoader
已弃用。改用ViewContainerRef.createComponent()
DynamicComponentLoader.loadAsRoot()
只能由bootstrap()
用于根组件,默认情况下不进行任何更改检测。您需要手动连接更改检测以使其正常工作
另见
构造函数(ref:ViewContainerRef)
然后从注入它的组件获取引用,或者可以使用@ViewChild(ComponentTypeOrTemplateVariableName,{read:ViewContainerRef})ref:ViewContainerRef代码>。以这种方式添加的组件被添加为ViewContainerRef
所属元素的同级。此外,您如何知道它已被弃用?这方面的参考文献在哪里?几个月以来,Angular团队成员在GitHub问题中多次提到这一点。我还没有看到它被添加到DynamicComponentLoader
中,以使其成为正式的
// bounded properties
public content: string;
public title: string;
public display(dialogOptions: IDialogParams, resolve: (boolean) => any){
document.onkeyup = null;
this._resolveAction = resolve;
this.setUpElements();
// here my bounded view properties are populated
this.populateViewProperties(dialogOptions);
this.wireEvents();
this._confirmElement.style.display = "block";
}