angular - Creating anchors outside component in Angular2 -


i trying make angular2 site using aspnet core 1.0. using standard template (not going design awards, want feeling angular2 , aspnet core 1.0, , how play together)

apart default auth controller, have 2 razor views. welcome page if not logged in, , page actual angular app.

the template basic bootstrap template navbar @ top. , here hard part. navbar part of shared razor layout, , therefore not angular component.

the old ngrouter used simple anchors navigate between views, far can tell new router requires links in template component. there way around that?

you can use hash location strategy (docs) [href] directive, considering have path defined in routeconfig. example:

your link somewhere outside of template

<a [href]="'#/users/new'">test</a> 

boot.ts

import {bootstrap} 'angular2/platform/browser'; import {appcomponent} './app'; import {router_providers, locationstrategy,hashlocationstrategy} 'angular2/router'; import {provide} 'angular2/core'  bootstrap(appcomponent, [router_providers, provide(locationstrategy, {useclass: hashlocationstrategy})]); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -