Reputation: 1506
I am trying to make a angular2 site using aspnet core 1.0. I am using the standard template for now (Not going for design awards, just want to get a feeling for angular2 and aspnet core 1.0, and how they play together)
Apart from the default auth controller, I have two razor views. A welcome page you get if you are not logged in, and a page with the actual angular app.
The template is something like the basic bootstrap template with a navbar at the top. And here is the hard part. The navbar is part of the shared razor layout, and therefore not the angular component.
The old ngRouter used simple anchors to navigate between views, but as far as I can tell the new router requires that the links are in template for the component. Is there any way around that?
Upvotes: 0
Views: 1081
Reputation: 558
You can use the hash location strategy (docs) with [href] directive, considering you have a path defined in RouteConfig. For example:
Your link somewhere outside of a template
<a [href]="'#/users/new'">Test</a>
boot.ts
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app';
import {ROUTER_PROVIDERS, LocationStrategy,HashLocationStrategy} from 'angular2/router';
import {provide} from 'angular2/core'
bootstrap(AppComponent, [ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})]);
Upvotes: 1