Created
August 14, 2014 21:19
-
-
Save antonmoiseev/fed2ef875da9f8a32dde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:angular/angular.dart'; | |
| import 'package:angular/application_factory.dart'; | |
| main() => applicationFactory().addModule(new AppModule()).run(); | |
| class AppModule extends Module { | |
| AppModule() { | |
| bind(HomeComponent); | |
| bind(RouteInitializerFn, toValue: _initRouter); | |
| bind(NgRoutingUsePushState, toFactory: (_) => new NgRoutingUsePushState.value(false)); | |
| } | |
| void _initRouter(Router router, RouteViewFactory viewFactory) { | |
| viewFactory.configure({ | |
| 'home': ngRoute( | |
| path: '/', | |
| viewHtml: '<h1>Home</h1><home-component></home-component>'), | |
| 'product': ngRoute( | |
| path: '/products', | |
| mount: { | |
| 'search': ngRoute( | |
| defaultRoute: true, | |
| viewHtml: '<h1>Search</h1>') | |
| }) | |
| }); | |
| } | |
| } | |
| @Component( | |
| selector: 'home-component', | |
| template: '<button ng-click="cmp.search()">Go to Search</button>', | |
| publishAs: 'cmp', | |
| useShadowDom: false) | |
| class HomeComponent { | |
| Router _router; | |
| HomeComponent(this._router); | |
| void search() { | |
| _router.go('product.search', { | |
| 'search.title': 'Item1' | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment