当我尝试使用* ngFor循环中的方法绑定名称时,无限循环在我的angular 6项目上运行。为什么会这样?并建议解决方案。谢谢...
if (this.code) {
this.appService.updateData('Users/clever_token', {code: this.code}).subscribe(data => {
if (data.detail) {
this.accessToken = data.detail.access_token;
this.appService.getCleverData('/v2.1/me', this.accessToken).subscribe(data1 => {
if (data1.links) {
this.userData.user_type = data1.type;
this.appService.getCleverData(data1.links[1].uri, this.accessToken).subscribe(data2 => {
if (data2.data) {
this.userData.name = data2.data.name.first + ' ' + data2.data.name.last;
this.userData.clever_id = data2.data.id;
this.userData.email = data2.data.email;
this.appService.updateData('Users/cleaver_login', this.userData).subscribe(data3 => {
if (data3.detail) {
console.log(data3.detail);
}
});
}
});
}
});
}
});
}
答案 0 :(得分:1)
在ts文件中:
public obj = {'Message_Centrel': 'Messaging', 'Admin': 'Admin', 'Catalog':
'Course Authoring'}
在html文件上:
<div *ngFor="let menu of MenuList">
<span>{{obj[menu.FullNameSpace] ? obj[menu.FullNameSpace] : '-'}}</span>
</div>