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

Commit 2563ff7

Browse files
committed
fix($controller): allow identifiers containing $
As discussed in #13664 (comment). Closes #13736
1 parent 0a641c0 commit 2563ff7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/ng/controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var $controllerMinErr = minErr('$controller');
44

55

6-
var CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/;
6+
var CNTRL_REG = /^(\S+)(\s+as\s+([\w$]+))?$/;
77
function identifierForController(controller, ident) {
88
if (ident && isString(ident)) return ident;
99
if (isString(controller)) {

test/ng/controllerSpec.js

+11
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,16 @@ describe('$controller', function() {
209209
"Badly formed controller string 'ctrl as'. " +
210210
"Must match `__name__ as __id__` or `__name__`.");
211211
});
212+
213+
214+
it('should allow identifiers containing `$`', function() {
215+
var scope = {};
216+
217+
$controllerProvider.register('FooCtrl', function() { this.mark = 'foo'; });
218+
219+
var foo = $controller('FooCtrl as $foo', {$scope: scope});
220+
expect(scope.$foo).toBe(foo);
221+
expect(scope.$foo.mark).toBe('foo');
222+
});
212223
});
213224
});

0 commit comments

Comments
 (0)