Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(ngController): change controllerAlias to controllerAs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Apr 29, 2013
1 parent 7812ae7 commit 400f936
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/ng/directive/ngView.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@
$routeProvider.when('/Book/:bookId', {
templateUrl: 'book.html',
controller: BookCntl,
controllerAlias: 'book'
controllerAs: 'book'
});
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
templateUrl: 'chapter.html',
controller: ChapterCntl,
controllerAlias: 'chapter'
controllerAs: 'chapter'
});
// configure html5 to get links working on jsfiddle
Expand Down Expand Up @@ -204,8 +204,8 @@ var ngViewDirective = ['$http', '$templateCache', '$route', '$anchorScroll', '$c
if (current.controller) {
locals.$scope = lastScope;
controller = $controller(current.controller, locals);
if (current.controllerAlias) {
lastScope[current.controllerAlias] = controller;
if (current.controllerAs) {
lastScope[current.controllerAs] = controller;
}
element.children().data('$ngControllerController', controller);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ng/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function $RouteProvider(){
* - `controller` – `{(string|function()=}` – Controller fn that should be associated with newly
* created scope or the name of a {@link angular.Module#controller registered controller}
* if passed as a string.
* - `controllerAlias` – `{string=}` – A controller alias name. If present the controller will be
* published to scope under the `controllerAlias` name.
* - `controllerAs` – `{string=}` – A controller alias name. If present the controller will be
* published to scope under the `controllerAs` name.
* - `template` – `{string=|function()=}` – html template as a string or function that returns
* an html template as a string which should be used by {@link ng.directive:ngView ngView} or
* {@link ng.directive:ngInclude ngInclude} directives.
Expand Down
2 changes: 1 addition & 1 deletion test/ng/directive/ngViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('ngView', function() {
};

module(function($compileProvider, $routeProvider) {
$routeProvider.when('/some', {templateUrl: '/tpl.html', controller: Ctrl, controllerAlias: 'ctrl'});
$routeProvider.when('/some', {templateUrl: '/tpl.html', controller: Ctrl, controllerAs: 'ctrl'});
});

inject(function($route, $rootScope, $templateCache, $location) {
Expand Down

0 comments on commit 400f936

Please sign in to comment.