[英]data is not binding to array in angular4 typescript?
I have event coming in using socket.io and pushed it to array object, Now i see its being added to array but its not updating or binding to the view if click on that component then i see it gets updated , Do we have something like ng-blur
options in angular 4 so we can achieve this task ? 我有事件进入使用socket.io并将其推送到数组对象,现在我看到它被添加到数组但它没有更新或绑定到视图,如果点击该组件然后我看到它得到更新,我们有类似的东西角度为4的
ng-blur
选项,以便我们可以完成这项任务吗?
secondConfigObject.data
is datasource of data grid i am using. secondConfigObject.data
是我正在使用的数据网格的数据源。
stream.component.ts stream.component.ts
ngOnInit() {
this.socket.on('newMessage', (newEvent) => {
console.log('New Event', newEvent);
this.sortArray(newEvent);
});
}
sortArray(newEvent){
var streamArray = this.secondConfigObject.data;
streamArray.push(Object.assign({},newEvent.data));
}
you can manually trigger using ChangeDetectorRef
您可以使用
ChangeDetectorRef
手动触发
constructor(private cdr:ChangeDetectorRef) {
}
sortArray(newEvent){
var streamArray = this.secondConfigObject.data;
streamArray.push(Object.assign({},newEvent.data));
this.cdr.detectChanges();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.