【发布时间】:2019-05-19 23:15:26
【问题描述】:
我有一个材料数据表,用户可以自己填写和清空。进入表的数据由服务触发,我在表组件中使用ngOnInit() 对其进行了初始化。
代码:
ngOnInit() {
this._AS.transaction$.subscribe( transaction => {
this.transaction = transaction;
this.temp = this.dataSource.data.slice();
this.temp.push(this.transaction); // Stop this call on init somehow?
this.dataSource.data = this.temp;
this.ref.detectChanges();
console.log(this.transaction);
}
);
}
问题是:总是有一个空行被调用this.temp.push(this.transaction) 推送。有没有办法第一次停止这个呼叫或类似的事情?
【问题讨论】:
标签: typescript service angular7 ngoninit