Skip to content

Instantly share code, notes, and snippets.

@sidthesloth92
Created April 3, 2016 15:23
Show Gist options
  • Save sidthesloth92/8a2188631109f9ef64871702b3716998 to your computer and use it in GitHub Desktop.
Save sidthesloth92/8a2188631109f9ef64871702b3716998 to your computer and use it in GitHub Desktop.
import {Component} from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {ViewOneComponent} from "./viewone.component";
import {ViewTwoComponent} from "./viewtwo.component";
import {ChildStatesRootComponent} from "./child-states/child-states-root.component";
@Component({
selector : 'my-app',
template : `<nav>
<a [routerLink]="['ViewOne']">View One</a>
<a [routerLink]="['ViewTwo', { routeParameter : '' }]">View Two</a>
<a [routerLink]="['ChildStatesRoot']">Child States Root</a>
<a [routerLink]="['ChildStatesRoot', { rootParam : 'rootParam' }, 'ChildStateTwo', { childParam : 'childParamValue'} ]">Go to Child Two Directly</a>
</nav>
<router-outlet></router-outlet>`,
directives : ROUTER_DIRECTIVES
})
@RouteConfig([
{
path : '/view-one',
name : 'ViewOne',
component : ViewOneComponent,
useAsDefault : true
},
{
path : '/view-two/:routeParameter',
name : 'ViewTwo',
component: ViewTwoComponent
},
{
path : '/child-states/...',
name : 'ChildStatesRoot',
component : ChildStatesRootComponent
}])
export class AppComponent {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment