| Index: third_party/pkg/angular/lib/routing/routing.dart
|
| diff --git a/third_party/pkg/angular/lib/routing/routing.dart b/third_party/pkg/angular/lib/routing/routing.dart
|
| index c40aa068402f68e7274be79a5749e0553cd80115..4a26bf6f862b80d2533cda4e7ec4fb5eb8734fbf 100644
|
| --- a/third_party/pkg/angular/lib/routing/routing.dart
|
| +++ b/third_party/pkg/angular/lib/routing/routing.dart
|
| @@ -3,42 +3,39 @@ part of angular.routing;
|
| /**
|
| * A factory of route to template bindings.
|
| */
|
| -class RouteViewFactory {
|
| +class ViewFactory {
|
| NgRoutingHelper locationService;
|
|
|
| - RouteViewFactory(this.locationService);
|
| + ViewFactory(this.locationService);
|
|
|
| call(String templateUrl) =>
|
| (RouteEnterEvent event) => _enterHandler(event, templateUrl);
|
|
|
| - _enterHandler(RouteEnterEvent event, String templateUrl,
|
| - {List<Module> modules, String templateHtml}) =>
|
| - locationService._route(event.route, templateUrl, fromEvent: true,
|
| - modules: modules, templateHtml: templateHtml);
|
| + _enterHandler(RouteEnterEvent event, String templateUrl, [List<Module> modules]) =>
|
| + locationService._route(event.route, templateUrl, fromEvent: true, modules: modules);
|
|
|
| configure(Map<String, NgRouteCfg> config) =>
|
| _configure(locationService.router.root, config);
|
|
|
| _configure(Route route, Map<String, NgRouteCfg> config) {
|
| config.forEach((name, cfg) {
|
| - var modulesCalled = false;
|
| + var moduledCalled = false;
|
| List<Module> newModules;
|
| route.addRoute(
|
| name: name,
|
| path: cfg.path,
|
| defaultRoute: cfg.defaultRoute,
|
| enter: (RouteEnterEvent e) {
|
| - if (cfg.view != null || cfg.viewHtml != null) {
|
| - _enterHandler(e, cfg.view,
|
| - modules: newModules, templateHtml: cfg.viewHtml);
|
| + if (cfg.view != null) {
|
| + _enterHandler(e, cfg.view, newModules);
|
| }
|
| if (cfg.enter != null) {
|
| cfg.enter(e);
|
| }
|
| },
|
| preEnter: (RoutePreEnterEvent e) {
|
| - if (cfg.modules != null && !modulesCalled) {
|
| - modulesCalled = true;
|
| + if (cfg.modules != null && !moduledCalled) {
|
| + moduledCalled = true;
|
| var modules = cfg.modules();
|
| if (modules is Future) {
|
| e.allowEnter(modules.then((List<Module> m) {
|
| @@ -63,18 +60,16 @@ class RouteViewFactory {
|
| }
|
| }
|
|
|
| -NgRouteCfg ngRoute({String path, String view, String viewHtml,
|
| - Map<String, NgRouteCfg> mount, modules(), bool defaultRoute: false,
|
| - RoutePreEnterEventHandler preEnter, RouteEnterEventHandler enter,
|
| - RouteLeaveEventHandler leave}) =>
|
| - new NgRouteCfg(path: path, view: view, viewHtml: viewHtml, mount: mount,
|
| - modules: modules, defaultRoute: defaultRoute, preEnter: preEnter,
|
| - enter: enter, leave: leave);
|
| +NgRouteCfg ngRoute({String path, String view, Map<String, NgRouteCfg> mount,
|
| + modules(), bool defaultRoute: false, RoutePreEnterEventHandler preEnter,
|
| + RouteEnterEventHandler enter, RouteLeaveEventHandler leave}) =>
|
| + new NgRouteCfg(path: path, view: view, mount: mount, modules: modules,
|
| + defaultRoute: defaultRoute, preEnter: preEnter, enter: enter,
|
| + leave: leave);
|
|
|
| class NgRouteCfg {
|
| final String path;
|
| final String view;
|
| - final String viewHtml;
|
| final Map<String, NgRouteCfg> mount;
|
| final Function modules;
|
| final bool defaultRoute;
|
| @@ -82,8 +77,8 @@ class NgRouteCfg {
|
| final RoutePreEnterEventHandler preEnter;
|
| final RouteLeaveEventHandler leave;
|
|
|
| - NgRouteCfg({this.view, this.viewHtml, this.path, this.mount, this.modules,
|
| - this.defaultRoute, this.enter, this.preEnter, this.leave});
|
| + NgRouteCfg({this.view, this.path, this.mount, this.modules, this.defaultRoute,
|
| + this.enter, this.preEnter, this.leave});
|
| }
|
|
|
| /**
|
| @@ -92,10 +87,12 @@ class NgRouteCfg {
|
| *
|
| * The [init] method will be called by the framework once the router is
|
| * instantiated but before [NgBindRouteDirective] and [NgViewDirective].
|
| + *
|
| + * Deprecated: use RouteInitializerFn instead.
|
| */
|
| -@Deprecated("use RouteInitializerFn instead")
|
| +@deprecated
|
| abstract class RouteInitializer {
|
| - void init(Router router, RouteViewFactory viewFactory);
|
| + void init(Router router, ViewFactory viewFactory);
|
| }
|
|
|
| /**
|
| @@ -105,21 +102,20 @@ abstract class RouteInitializer {
|
| * The function will be called by the framework once the router is
|
| * instantiated but before [NgBindRouteDirective] and [NgViewDirective].
|
| */
|
| -typedef void RouteInitializerFn(Router router, RouteViewFactory viewFactory);
|
| +typedef void RouteInitializerFn(Router router, ViewFactory viewFactory);
|
|
|
| /**
|
| * A singleton helper service that handles routing initialization, global
|
| * events and view registries.
|
| */
|
| -@Injectable()
|
| +@NgInjectableService()
|
| class NgRoutingHelper {
|
| final Router router;
|
| - final Application _ngApp;
|
| - List<NgView> portals = <NgView>[];
|
| + final NgApp _ngApp;
|
| + List<NgViewDirective> portals = <NgViewDirective>[];
|
| Map<String, _View> _templates = new Map<String, _View>();
|
|
|
| - NgRoutingHelper(RouteInitializer initializer, Injector injector, this.router,
|
| - this._ngApp) {
|
| + NgRoutingHelper(RouteInitializer initializer, Injector injector, this.router, this._ngApp) {
|
| // TODO: move this to constructor parameters when di issue is fixed:
|
| // https://github.com/angular/di.dart/issues/40
|
| RouteInitializerFn initializerFn = injector.get(RouteInitializerFn);
|
| @@ -129,22 +125,22 @@ class NgRoutingHelper {
|
| };
|
|
|
| if (initializerFn != null) {
|
| - initializerFn(router, new RouteViewFactory(this));
|
| + initializerFn(router, new ViewFactory(this));
|
| } else {
|
| - initializer.init(router, new RouteViewFactory(this));
|
| + initializer.init(router, new ViewFactory(this));
|
| }
|
| router.onRouteStart.listen((RouteStartEvent routeEvent) {
|
| routeEvent.completed.then((success) {
|
| if (success) {
|
| - portals.forEach((NgView p) => p._maybeReloadViews());
|
| + portals.forEach((NgViewDirective p) => p._maybeReloadViews());
|
| }
|
| });
|
| });
|
|
|
| - router.listen(appRoot: _ngApp.element);
|
| + router.listen(appRoot: _ngApp.root);
|
| }
|
|
|
| - void _reloadViews({Route startingFrom}) {
|
| + _reloadViews({Route startingFrom}) {
|
| var alreadyActiveViews = [];
|
| var activePath = router.activePath;
|
| if (startingFrom != null) {
|
| @@ -155,38 +151,36 @@ class NgRoutingHelper {
|
| if (viewDef == null) continue;
|
| var templateUrl = viewDef.template;
|
|
|
| - NgView view = portals.lastWhere((NgView v) {
|
| + NgViewDirective view = portals.lastWhere((NgViewDirective v) {
|
| return _routePath(route) != _routePath(v._route) &&
|
| _routePath(route).startsWith(_routePath(v._route));
|
| }, orElse: () => null);
|
| if (view != null && !alreadyActiveViews.contains(view)) {
|
| - view._show(viewDef, route, viewDef.modules);
|
| + view._show(templateUrl, route, viewDef.modules);
|
| alreadyActiveViews.add(view);
|
| break;
|
| }
|
| }
|
| }
|
|
|
| - void _route(Route route, String template, {bool fromEvent, List<Module> modules,
|
| - String templateHtml}) {
|
| - _templates[_routePath(route)] = new _View(template, templateHtml, modules);
|
| + _route(Route route, String template, {bool fromEvent, List<Module> modules}) {
|
| + _templates[_routePath(route)] = new _View(template, modules);
|
| }
|
|
|
| - void _registerPortal(NgView ngView) {
|
| + _registerPortal(NgViewDirective ngView) {
|
| portals.add(ngView);
|
| }
|
|
|
| - void _unregisterPortal(NgView ngView) {
|
| + _unregisterPortal(NgViewDirective ngView) {
|
| portals.remove(ngView);
|
| }
|
| }
|
|
|
| class _View {
|
| final String template;
|
| - final String templateHtml;
|
| final List<Module> modules;
|
|
|
| - _View(this.template, this.templateHtml, this.modules);
|
| + _View(this.template, this.modules);
|
| }
|
|
|
| String _routePath(Route route) {
|
|
|