Nativescript Angular - No provider for Router! (RC4 - Router 3.0.0-beta.2)

怎甘沉沦 提交于 2019-12-12 03:49:37

问题


The following Nativescript Angular application- demonstrates navigation using <router-outlet></router-outlet> - but after to ANGULAR "2.0.0-rc.4" and ROUTER "3.0.0-beta.2", the application fails to load.

ERROR thrown:

No provider for Router!


JS: EXCEPTION: Error in ./AppComponent class AppComponent_Host - inline template:0:0 JS: ORIGINAL EXCEPTION: No provider for Router! JS: ORIGINAL STACKTRACE: JS: Error: DI Exception JS:     at NoProviderError.BaseException [as constructor] (/data/data/org.nativescript.testapp/files/app/tns_modules/@angular/core/src/facade/exceptions.js:27:23)

回答1:


The current official version of nativescript-angular package depends on RC3 @angular code and will probably wont work well with RC4 (there are some internal changes that will break it). However, you can try using the @next builds of nativescript-angular that are already migrated to use RC4.

Check here for more info on how to do that.




回答2:


I'm not sure about the actual issue. But I'm guessing, problem is in main.ts.

nativeScriptBootstrap(AppComponent, [AppComponent,HTTP_PROVIDERS,app_globals]);

add APP_ROUTER_PROVIDERS to it. So it will be:

nativeScriptBootstrap(AppComponent, [AppComponent,HTTP_PROVIDERS,app_globals, APP_ROUTER_PROVIDERS]);



来源:https://stackoverflow.com/questions/38522706/nativescript-angular-no-provider-for-router-rc4-router-3-0-0-beta-2

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