Angular Ngif else异步数据

Angular Ngif else异步数据,angular,angular2-template,angular6,angular2-directives,Angular,Angular2 Template,Angular6,Angular2 Directives,我不想看到错误模板,因为我正在等待来自API的数据,我希望spinner继续加载,直到调用API数据为止。现在我得到了微调器,然后是错误模板,然后是API绑定的数据,这在逻辑上是错误的 导入{ 组成部分, 奥尼特 }从“@angular/core”开始; 进口{ forkJoin, 订阅 }来自‘rxjs’; 进口{ 激活路由, Params }来自“@angular/router”; 进口{ 开关图 }来自“rxjs/运营商”; 进口{ 订单50服务 }来自“../services/orde

我不想看到错误模板,因为我正在等待来自API的数据,我希望spinner继续加载,直到调用API数据为止。现在我得到了微调器,然后是错误模板,然后是API绑定的数据,这在逻辑上是错误的

导入{
组成部分,
奥尼特
}从“@angular/core”开始;
进口{
forkJoin,
订阅
}来自‘rxjs’;
进口{
激活路由,
Params
}来自“@angular/router”;
进口{
开关图
}来自“rxjs/运营商”;
进口{
订单50服务
}来自“../services/orders-m50.service”;
进口{
M50详细信息
}来自“../interfaces/order-m50.interface”;
进口{
查找服务
}来自“../shared/services/lookup.service”;
进口{
DCLookup,
OrderTypeLookup
}来自“../shared/models/lookups.interface”;
@组成部分({
选择器:“idl-m50-deliver-update”,
templateUrl:'./m50 deliver update.component.html',
样式URL:['./m50 deliver update.component.scss']
})
导出类M50DeliverUpdateComponent实现OnInit{
公共秩序:M50Detail;
公共加载=错误;
public orderType:OrderTypeLookup;
公共dc:DCLookup;
公开错误:任何;
私人_paramsub$:认购;
私有_id:string;
构造器(专用)ordersService:OrdersM50Service,
private\u lookupService:lookupService,
专用_路由:ActivatedRoute){
ngOnInit():void{
这是。加载=真;
//log(errorHandler);
this.\u paramsub$=this.\u route.params
.pipe(开关映射((参数:参数)=>{
这个。_id=params['id'];
const orderRequest=this.\u ordersService.getM50ById(this.\u id);
const orderTypeRequest=this.\u lookupService.getOrderTypesM50();
const dcRequest=this.\u lookupService.getDCs();
返回forkJoin([orderRequest,orderTypeRequest,dcRequest]);
}))
.订阅((结果:[
M50详细信息,
数组,
数组
]) => {
log('FORKJOIN RESULT',RESULT);
this.order=结果[0];
this.orderType=this.\u getLookUpItemById(结果[1],this.order.order\u类型);
this.dc=this.\u getLookUpItemById(结果[2],this.order.dc);
这一点:加载=错误;
},err=>{
控制台日志(err);
this.error=err;
这一点:加载=错误;
});
}
}

M50视图
您的情况是

*ngIf="order; else errorCont"
当然,如果不在错误变量上设置条件,您将看到错误消息

鉴于您有
订单
加载
错误
,以下是您的条件:



没问题,如果这对你有帮助,考虑一下投票吧,如果它解决了你的问题,考虑把你的问题标记为解决!