Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:angular2/angular2.dart';
- import 'package:angular2/router.dart';
- @Component(
- selector: 'routing-page')
- @View(directives: const [RouterLink, RouterOutlet],
- template: '<div>RoutingPage</div>'
- '<a [routerLink]="[\'Project\', {\'idProject\': \'1\'}]">Project 1 </a>'
- '<a [routerLink]="[\'Project\', {\'idProject\': \'2\'}]">Project 2 </a>'
- '<a [routerLink]="[\'Project\', {\'idProject\': \'3\'}]">Project 3 </a>'
- '<router-outlet></router-outlet>')
- @RouteConfig(const [
- const Route(path: '/help', component: HelpPage, name: 'HelpPage'),
- const Route(path: '/project/:idProject/...', component: ProjectPage, name: 'Project'),
- const Route(path: '/', component: HomePage, name: 'Default', useAsDefault: true)
- ])
- class RoutingPage
- {
- }
- @Component(selector: 'home-page')
- @View(template: '<div>Home Page</div>')
- class HomePage
- {
- }
- @Component(selector: 'help-page')
- @View(template: '<div>Help page</div>')
- class HelpPage
- {
- }
- @Component(selector: 'project-page')
- @View(directives: const [RouterLink, RouterOutlet],
- template: '<div>Project page. Project: {{idProject}}</div>'
- '<a [routerLink]="[\'Year\', {\'idYear\': \'2013\'}]">2013 </a>'
- '<a [routerLink]="[\'Year\', {\'idYear\': \'2014\'}]">2014 </a>'
- '<a [routerLink]="[\'Year\', {\'idYear\': \'2015\'}]">2015 </a>'
- '<router-outlet></router-outlet>')
- @RouteConfig(const [
- const Route(path: '/year/:idYear/...', component: YearPage, name: 'Year'),
- const Route(path: '/', component: ProjectDefaultPage, name: 'Default', useAsDefault: true)
- ])
- class ProjectPage implements CanReuse, OnReuse
- {
- String idProject;
- ProjectPage(RouteParams params)
- {
- idProject = params.get("idProject");
- }
- dynamic routerCanReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction)
- {
- return true;
- }
- dynamic routerOnReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction)
- {
- return true;
- }
- }
- @Component(selector: 'project-default-page')
- @View(template:'<div>Default project page</div>')
- class ProjectDefaultPage
- {
- }
- @Component(selector: 'year-page')
- @View(directives: const [RouterLink, RouterOutlet],
- template: '<div>Year page. Year: {{idYear}}</div>'
- '<a [routerLink]="[\'Month\', {\'idMonth\': \'1\'}]">1 </a>'
- '<a [routerLink]="[\'Month\', {\'idMonth\': \'2\'}]">2 </a>'
- '<a [routerLink]="[\'Month\', {\'idMonth\': \'3\'}]">3 </a>'
- '<router-outlet></router-outlet>')
- @RouteConfig(const [
- const Route(path: '/month/:idMonth', component: MonthPage, name: 'Month'),
- const Route(path: '/', component: YearDefaultPage, name: 'Default', useAsDefault: true)
- ])
- class YearPage implements CanReuse, OnReuse
- {
- String idYear;
- YearPage(RouteParams params)
- {
- idYear = params.get("idYear");
- }
- dynamic routerCanReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction)
- {
- return true;
- }
- dynamic routerOnReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction)
- {
- return true;
- }
- }
- @Component(selector: 'year-default-page')
- @View(template:'<div>Default Year page</div>')
- class YearDefaultPage
- {
- }
- @Component(selector: 'month-page')
- @View(template:'<div>Month page. Month: {{idMonth}}</div>')
- class MonthPage implements CanReuse, OnReuse
- {
- String idMonth;
- MonthPage(RouteParams params)
- {
- idMonth = params.get("idMonth");
- }
- dynamic routerCanReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction)
- {
- return true;
- }
- dynamic routerOnReuse(ComponentInstruction nextInstruction, ComponentInstruction prevInstruction)
- {
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement