From edad8e3f565680ed491dd4f900a40f5d215184e1 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Mon, 22 Feb 2016 14:01:02 +0000 Subject: [PATCH] fix(angular1_router): rename `router` component binding to `$router` The current router is passed to the current component via a binding. To indicate that this is an angular provided object, this commit renames the binding to `$router`. BREAKING CHANGE: The recently added binding of the current router to the current component has been renamed from `router` to `$router`. So now the recommended set up for your bindings in your routed component is: ```js { ... bindings: { $router: '<' } } ``` --- modules/angular1_router/src/ng_outlet.ts | 4 ++-- modules/angular1_router/test/integration/router_spec.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/angular1_router/src/ng_outlet.ts b/modules/angular1_router/src/ng_outlet.ts index ab7ea56580..7572d92ff2 100644 --- a/modules/angular1_router/src/ng_outlet.ts +++ b/modules/angular1_router/src/ng_outlet.ts @@ -155,7 +155,7 @@ function ngOutletDirective($animate, $q: ng.IQService, $router) { } this.controller.$$template = - '<' + dashCase(componentName) + ' router="$$router">'; + '<' + dashCase(componentName) + ' $router="$$router">'; this.controller.$$router = this.router.childRouter(instruction.componentType); this.controller.$$outlet = this; @@ -294,7 +294,7 @@ angular.module('ngComponentRouter', []) .directive('ngOutlet', ['$animate', '$q', '$router', ngOutletDirective]) .directive('ngOutlet', ['$compile', ngOutletFillContentDirective]) .directive('ngLink', ['$router', '$parse', ngLinkDirective]) - .directive('router', ['$q', routerTriggerDirective]); + .directive('$router', ['$q', routerTriggerDirective]); /* * A module for inspecting controller constructors diff --git a/modules/angular1_router/test/integration/router_spec.js b/modules/angular1_router/test/integration/router_spec.js index 935ab8b2ce..7c8eb1150e 100644 --- a/modules/angular1_router/test/integration/router_spec.js +++ b/modules/angular1_router/test/integration/router_spec.js @@ -47,10 +47,10 @@ describe('router', function () { it('should bind the component to the current router', inject(function($location) { var router; registerComponent('homeCmp', { - bindings: { router: '=' }, + bindings: { $router: '=' }, controller: function($scope, $element) { this.$routerOnActivate = function() { - router = this.router; + router = this.$router; }; }, template: 'Home' @@ -69,7 +69,7 @@ describe('router', function () { $rootScope.$digest(); var homeElement = elt.find('home-cmp'); expect(homeElement.text()).toBe('Home'); - expect(homeElement.isolateScope().$ctrl.router).toBeDefined(); + expect(homeElement.isolateScope().$ctrl.$router).toBeDefined(); expect(router).toBeDefined(); }));