數據表一旦呈現後,我無法更新數據。 我正在使用angular2-datatable。angular2-datatable無法更新數據
在我appcomponent.html:
如果我更新數據2在我appcomponent.ts文件中像這樣:
this.httpservice.getdata().subscribe
(data=>
{ this.data2=data;
for (i = 0; i < 21; i++) {
markerarray[i] = new google.maps.Marker({
position: new google.maps.LatLng(this.data2[i].latituide, this.data2
[i].longituide), //In this line
title: this.data2[i].name, //and this
map: map
});
}
google.maps.event.addListener(map, 'idle', function() {
var bounds = map.getBounds();
for (var i = 0; i < 20; i++) {
var marker = markerarray[i];
if (bounds.contains(marker.getPosition()) === true) {
this.data2.length=0;// This is not working for me
}
}
});
})
我要清空數據表,一旦指標有界。
嘗試做this.data2 = [] –
使用'箭頭function'保留'this',而不是'{功能' – yurzui
@JuliaPassynkova我嘗試這樣做。但它仍然沒有更新:( – mistletoe