Skip to content
Permalink
Browse files

fix($controller): allow identifiers containing `$`

As discussed in #13664 (comment).

Closes #13736
  • Loading branch information
gkalpak committed Jan 11, 2016
1 parent 0a641c0 commit 2563ff7ba92d84af978e7e4131253190d4d00c20
Showing with 12 additions and 1 deletion.
  1. +1 −1 src/ng/controller.js
  2. +11 −0 test/ng/controllerSpec.js
@@ -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)) {
@@ -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.
You can’t perform that action at this time.