【发布时间】:2016-08-26 02:24:38
【问题描述】:
据我了解,您为刚刚使用 DynamicComponentLoader 添加到 DOM 的组件设置 @Input 变量的方式是在调用类似 loadIntoLocation 的内容后使用 promise 块:
this.dcl.loadIntoLocation( Lorem, this.elRef, 'target')
.then( cmpRef => {
cmpRef.instance.foo = _self.baz;
});
export class Lorem {
public @Input() foo : String;
...
我的问题是在使用动态组件加载器时如何设置@Output?
this.dcl.loadIntoLocation( Lorem, this.elRef, 'target')
.then( cmpRef => {
cmpRef.instance.foo = _self.baz;
cmpRef.instance.changer = _self.change($event);
});
export class Lorem {
public @Input() foo : String;
@Output() changer = new EventEmitter();
...
...
this.changer.emit("event");
非常感谢您提供的帮助。
【问题讨论】:
-
DynamicComponentLoader添加的组件不支持@Input()和@Output()
标签: input angular output eventemitter