如何在Angular 2.0.0中解析数据时显示服务员?

时间:2016-10-12 11:52:59

标签: javascript angular typescript router angular2-routing

我的项目基于Angular 2.0.0,我希望在导航路线时显示服务员(gif或文本),这必须解决这样的数据:

   { 
      path: 'profile',
      loadChildren: () => System.import('../profile/profile.module'),
      resolve: {
        profile: ProfileResolver
      },
    },

此外,预加载器需要应用于项目中的每个路径。 感谢。

1 个答案:

答案 0 :(得分:0)

我会说你可以根据NavigationStart&amp ;;创建一个能够继续关注路由事件的服务。 NavigationEnd事件show/hide根据isLoading标记值与[hidden]的组合加载isLoading: bool = false; constructor(router:Router) { router.events.subscribe(event:Event => { if(event instanceof NavigationStart) { this.isLoading = true; } if(event instanceof NavigationCancel || event instanceof NavigationError) { this.isLoading = false; } } }

<强>代码

git clone https://github.com/CocoaPods/Specs.git