ng-zorro 级联输入框懒加载时,load方法里this=undefined
如题,代码如下:
<nz-cascader
\[nzLoadData\]\="loadCityBuildingData"
\[(ngModel)\]\="selectedLocation"
(ngModelChange)\="onNewLocationModalChanges($event)"
\> </nz-cascader>
loadCityBuildingData(node: NzCascaderOption, index: number): PromiseLike<void\> {
console.log(this);
return new Promise(resolve => {
if (index < 0) {
this.cityService.getCities().subscribe(item => {
const cities = \[\];
item.forEach(city => {
cities.push({value: city.id, label: city.name});
});
node.children \= cities;
resolve();
});
} else if (index === 0) {
this.buildingService.getBuildingsByCityId(node.value).subscribe(item => {
const buildings = \[\];
item.forEach(building => {
buildings.push({value: building.id, label: building.name, isLeaf: true});
});
node.children \= buildings;
resolve();
});
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遇到相同的问题,不知道解决了没 哭o(╥﹏╥)o
用箭头函数,或者绑定this