Angular 角度2动态组件双向绑定
请帮助我了解如何从父级到动态创建的组件进行双向数据绑定 以下是父组件部件:Angular 角度2动态组件双向绑定,angular,data-binding,dynamic-compilation,Angular,Data Binding,Dynamic Compilation,请帮助我了解如何从父级到动态创建的组件进行双向数据绑定 以下是父组件部件: ngOnInit() { let factory: ComponentFactory<any> = this._componentFactoryResolver.resolveComponentFactory(this.ComponentType); this._Component = this._viewContainer.createComponent(factory); this
ngOnInit() {
let factory: ComponentFactory<any> =
this._componentFactoryResolver.resolveComponentFactory(this.ComponentType);
this._Component = this._viewContainer.createComponent(factory);
this._Component.instance.Value = this.Value;
this._Component.changeDetectorRef.detectChanges(); // What does it do? :(
}
父项或子项中的任何值更改都不会相互影响。
对我来说,没有看到任何一行代码进行数据绑定并不奇怪
请帮帮我,或者给我一个正确的挖掘方法
多谢各位
@Input() Value: any; // But I think @Input decorator is useless here?