I searched the net to get an example of angular2 router that changes browser urls. All examples that are there doesn't change browser urls when we change different routes. Can you give me a small example in ES6 to demonstrate this?
An example.
On a Component class:
@RouteConfig([
{ path: '/', name: 'home', component: Home },
{ path: '/dashboard', name: 'dashboard', component: Dashboard },
{ path: '/todo', name: 'todo', component: Todo }
])
export class App {}
name
is not necessary, but can be used to provide an alias.
In the template:
<a router-link="home">Home</a>
Note that router-link
must exist on an <a>
tag.