diff --git a/src/ng/controller.js b/src/ng/controller.js index 4e64f3417a88..389f869c9888 100644 --- a/src/ng/controller.js +++ b/src/ng/controller.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)) { diff --git a/test/ng/controllerSpec.js b/test/ng/controllerSpec.js index 839e3310c5e6..253623d05a42 100644 --- a/test/ng/controllerSpec.js +++ b/test/ng/controllerSpec.js @@ -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'); + }); }); });