I have implemented Angular 2 for routing and Node for local hosting.
However, I encountered an issue where using 'useAsDefault:true' for my route caused the nav bar links to stop functioning properly. The URL would redirect to http://localhost/ (Blank Page) instead of http://localhost/home.
Upon removing the flag, the nav bar worked correctly and I was able to navigate to the /home route without encountering the blank page error.
Can someone help me understand why the default flag is not behaving as expected?
App.Component.ts
@RouteConfig([
{ path: '/home', name: 'Home', component: HomeComponent /*, useAsDefault : true */},
{ path: '/articles', name: 'Posts', component: PostsComponent },
{ path: '/detail/:id', name: 'PostDetail', component: PostDetailComponent },
{ path: '/login', name: 'Login', component: LoginComponent },
])
App.Component.html
<ul class="topnav">
<li><a [routerLink]="['Home']">Home</a></li>
<li><a [routerLink]="['Posts']">Articles</a></li>
<li><a href="#p">Publisher</a></li>
<li><a [routerLink]="['Login']">Login</a></li>
</ul>
<router-outlet></router-outlet>
Main.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { HTTP_PROVIDERS } from '@angular/http';
import { ROUTER_PROVIDERS } from '@angular/router-deprecated';
bootstrap(AppComponent, [ROUTER_PROVIDERS, HTTP_PROVIDERS]);
index.html
<html>
<head>
<script>document.write('<base href="' + document.location + '" />');</script>
<title>Blog</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles/styles.css">
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<!-- 3. Display the application -->
<body>
<blog-app>Blog Loading...</blog-app>
</body>
</html>