Angular2's provide() function deprecated in RC4 and later, what should be used instead?

拟墨画扇 提交于 2020-01-01 03:54:08

问题


I just upgraded from Angular2 RC1 to RC4.

Before I used:

provide(LocationStrategy, {useClass: HashLocationStrategy})

However, after upgraded to RC4, the provide shows as deprecated.

I did not find any documentation on this.

Does anyone have an idea about what happened?


回答1:


As was pointed out in the comments above, you should now just use an object with provide and useClass properties, such as in the following:

bootstrap(App, [
    CookieService,
    AuthService,
    WindowService,
    COMMON_DIRECTIVES,
    ROUTER_DIRECTIVES,
    HTTP_PROVIDERS,
    provideRouter(AppRoutes),
    { provide: LocationStrategy, useClass: HashLocationStrategy }
]);

This example is from my Github project using Angular2, Bootstrap 4, OAuth2, and Webpack. I've been updating it as the various alpha, beta, and RC releases of Angular2 have been put out.



来源:https://stackoverflow.com/questions/38148302/angular2s-provide-function-deprecated-in-rc4-and-later-what-should-be-used-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!