2016-07-26 76 views
1

在以前的版本我提供AuthHttp爲法洛斯:如何提供AuthHttp角RC4由於提供的depricated

return bootstrap(<any>App, [ 
    // These are dependencies of our App 
     ...FORM_PROVIDERS, 
     ...HTTP_PROVIDERS, 
     ...ROUTER_PROVIDERS, 
     ...ENV_PROVIDERS, 
     provide(AuthHttp, { 
      useFactory: (http) => { 
       return new AuthHttp(new AuthConfig({ 
        tokenName: 'jwt' 
       }), http); 
      }, 
      deps: [Http] 
     }), 
     provide(APP_BASE_HREF, {useValue : '/' }) 
    ]).catch(err => console.error(err)); 

但在RC4 +提供已被廢棄,棄用警告即將到來。 那麼如何改變這些兼容的更高版本。

回答

3

提供變更爲傳遞一個對象,而不是函數:

return bootstrap(<any>App, [ 
    // These are dependencies of our App 
    ...FORM_PROVIDERS, 
    ...HTTP_PROVIDERS, 
    ...ROUTER_PROVIDERS, 
    ...ENV_PROVIDERS, 
    { 
     provide: AuthHttp, 
     useFactory: (http) => { 
      return new AuthHttp(new AuthConfig({ 
       tokenName: 'jwt' 
      }), http); 
     }, 
     deps: [Http] 
    }, 
    { 
     provide: APP_BASE_HREF, 
     useValue : '/' 
    } 
]).catch(err => console.error(err));