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: '<'
  }
}
```
This commit is contained in:
Peter Bacon Darwin 2016-02-22 14:01:02 +00:00 committed by Pete Bacon Darwin
parent d4a4d81173
commit edad8e3f56
2 changed files with 5 additions and 5 deletions

View File

@ -155,7 +155,7 @@ function ngOutletDirective($animate, $q: ng.IQService, $router) {
}
this.controller.$$template =
'<' + dashCase(componentName) + ' router="$$router"></' + dashCase(componentName) + '>';
'<' + dashCase(componentName) + ' $router="$$router"></' + dashCase(componentName) + '>';
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

View File

@ -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();
}));