在角度5中导航后如何继续下一个代码?

时间:2018-11-16 18:30:20

标签: angular

        this.loading = true;
        this.subscription = this.orderService.approveOrder(this.orderDraft.orderId)
            .subscribe((result: any) => {
                if (result) {
                    this.router.navigate([`/${ODRootMenu}s/`])
                    this.successDialog(Message.TITLE_INIT_ORDER_APPROVAL_SUCCESSFULLY, Message.BODY_ORDER_APPROVAL_SUCCESSFULLY(this.orderDraft.orderId));
                    this.loading = false;
                }
            }, (error: any) => { console.log(error); });

在this.router.navigate([/${ODRootMenu}s/])之后,如何等待新路由器的所有服务加载并显示successDialog,加载指示器?

1 个答案:

答案 0 :(得分:0)

this.router.navigate是一个承诺,如果导航完成,它将返回true。您可以像这样使用它作为示例:

this.router.navigate([`/${ODRootMenu}s/`]).then(() =>
{
    this.successDialog(Message.TITLE_INIT_ORDER_APPROVAL_SUCCESSFULLY, 
      Message.BODY_ORDER_APPROVAL_SUCCESSFULLY(this.orderDraft.orderId));
    this.loading = false;
})