Skip to content

Instantly share code, notes, and snippets.

@antonmoiseev
Created August 14, 2014 21:19
Show Gist options
  • Select an option

  • Save antonmoiseev/fed2ef875da9f8a32dde to your computer and use it in GitHub Desktop.

Select an option

Save antonmoiseev/fed2ef875da9f8a32dde to your computer and use it in GitHub Desktop.
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