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

Commit

Permalink
fix($controller): allow identifiers containing $
Browse files Browse the repository at this point in the history
As discussed in #13664 (comment).

Closes #13736
  • Loading branch information
gkalpak committed Jan 12, 2016
1 parent 0a641c0 commit 2563ff7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var $controllerMinErr = minErr('$controller');


var CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/;
var CNTRL_REG = /^(\S+)(\s+as\s+([\w$]+))?$/;
function identifierForController(controller, ident) {
if (ident && isString(ident)) return ident;
if (isString(controller)) {
Expand Down
11 changes: 11 additions & 0 deletions test/ng/controllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,16 @@ describe('$controller', function() {
"Badly formed controller string 'ctrl as'. " +
"Must match `__name__ as __id__` or `__name__`.");
});


it('should allow identifiers containing `$`', function() {
var scope = {};

$controllerProvider.register('FooCtrl', function() { this.mark = 'foo'; });

var foo = $controller('FooCtrl as $foo', {$scope: scope});
expect(scope.$foo).toBe(foo);
expect(scope.$foo.mark).toBe('foo');
});
});
});

0 comments on commit 2563ff7

Please sign in to comment.