zoukankan      html  css  js  c++  java
  • angular2 学习笔记 ( app initialize 初始化 )

    refer : http://stackoverflow.com/questions/39033835/angularjs2-preload-server-configuration-before-the-application-starts ( angular initialize )

    直接上代码 

    @NgModule({
        imports: [
            StoogesModule,
            IdentityRoutingModule
        ],
        exports: [],
        declarations: [LoginComponent],
        providers: [
            IdentityService,        
            {
                provide: APP_INITIALIZER,
                useFactory: IdentityInitializeFactory, //这里不要用匿名函数, webpack 会报错
                deps: [IdentityService],
                multi: true
            },
            AdminAuthorizeGuard,
            ShopAuthorizeGuard
        ],
    })
    export class IdentityModule { }

    factory 返回方法, 然后返回 promise.

    export function IdentityInitializeFactory (identityService: IdentityService)
    {
        return async () => { 
            await identityService.getUserByCookies(); 
        }
    }

     

  • 相关阅读:
    read_csv 函数
    fillna()
    一个逗号引发的错误
    数据预处理
    groupby()
    泰坦尼克号 预处理
    python string
    python title()的用法
    translate()函数及ROT13加密
    python Lambda, filter, reduce and map
  • 原文地址:https://www.cnblogs.com/keatkeat/p/6358068.html
Copyright © 2011-2022 走看看