Angular2 + Cordoba - Unable to map routes at startup

I have a problem with an Angular2 application when I create it for Android (maybe this problem also occurs in iOS, but I have not tested it yet). When starting up, the following error message appears:

EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'android_asset'. Available routes: ['', '/login', '/register', '/lostpw', '/resetpw', '/content']. 

Because of this, the application start page does not load. To make the application work at all, I had to replace the base tag in index.html from

  <base href="/"> 

to

  <base href="file:///android_asset/www/" target="_blank"> 

But as said, the router is trying to enable android_asset. With the application, I can click on a menu item like

  <a [routerLink]="['/']">Home</a> 

and I successfully redirected to the home route.

Does anyone know how to solve the problem at startup?

Version: Angular 2.0.0-rc.1

+2
source share
2 answers

For '' redirct to home

export const StartRoutes: RouterConfig = [ { path: '', redirectTo: '/home' } ];

+2
source

For me it was allowed to use './' for the base href. This solved this problem and several other problems.

0
source

All Articles