Angular 带异步管道的角度*ngFor不';不显示数据
标题说明了一切,所以我将向您展示代码 TSAngular 带异步管道的角度*ngFor不';不显示数据,angular,ngfor,angular2-observables,Angular,Ngfor,Angular2 Observables,标题说明了一切,所以我将向您展示代码 TS notificationsChannels: Observable<{ name: string }[]>; ngOnInit() { this.notificationsChannels = this._notificationsManagerService .getAll(this.endPoint) .pipe( map(res =>
notificationsChannels: Observable<{ name: string }[]>;
ngOnInit() {
this.notificationsChannels = this._notificationsManagerService
.getAll(this.endPoint)
.pipe(
map(res =>
res.body.map(config => {
return { name: config['entityName'] };
})
)
);
}
notificationsChannels:可见;
恩戈尼尼特(){
this.notificationsChannels=this.\u notificationsManager服务
.getAll(此.endPoint)
.烟斗(
地图(res=>
res.body.map(配置=>{
返回{name:config['entityName']};
})
)
);
}
模板
<p-tabView>
<p-tabPanel [header]="channel.name | humanizeText" *ngFor="let channel of (notificationsChannels | async)">
</p-tabPanel>
</p-tabView>
虽然数据到达,但模板不会重新设置它。也许我遗漏了什么…尝试将代码更改为:
<p-tabView>
<ng-container *ngFor="let channel of notificationsChannels | async">
<p-tabPanel [header]="channel.name | humanizeText">
</p-tabPanel>
</ng-container>
</p-tabView>
尝试将代码更改为:
<p-tabView>
<ng-container *ngFor="let channel of notificationsChannels | async">
<p-tabPanel [header]="channel.name | humanizeText">
</p-tabPanel>
</ng-container>
</p-tabView>
有时这些选项卡组件无法处理动态创建的子项。因此,您可以尝试延迟创建所有内容,直到异步数据可用
有时这些选项卡组件无法处理动态创建的子项。因此,您可以尝试延迟创建所有内容,直到异步数据可用
确保getAll方法返回它所做的事情。我肯定!!!我不认为这是问题所在,但是括号在“NotificationsAnnels | async”周围是无用的,我已经尝试过不用它们了……确保getAll方法返回了它所能返回的东西。我肯定!!!我不认为这是问题所在,但括号在“NotificationsAnnels | async”周围是无用的,我已经尝试过不用它们了。。。