【发布时间】:2026-01-11 08:40:01
【问题描述】:
我的父页面如下所示。
html:
<counter [conversationId]="conversationId"></counter>
组件:
public conversationId: string;
public showModal() {
this.conversationId = '1234'
this.modalService.showComponent(CounterPage, { class: 'modal-lg' });
}
我的孩子页面如下所示。
@Input() conversationId: any;
public ngOnInit (): void {
alert(this.conversationId); //shows undefinded.
}
看起来这是常见问题here。没有一个解决方案对我有用。
【问题讨论】:
-
传入时
conversationId是什么?如果您传入undefined,那么它仍然是undefined是有道理的。 -
我没有通过 undefined。我的代码清楚地显示在调用 show 组件之前将“1234”分配给 conversationId
标签: angular