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

Commit de2cdb0

Browse files
committed
fix(ngController): allow dots in a controller name
The issue was introduced in cd38cbf
1 parent cda7b71 commit de2cdb0

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/ng/controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
function $ControllerProvider() {
1414
var controllers = {},
15-
CNTRL_REG = /^(\w+)(\s+as\s+(\w+))?$/;
15+
CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/;
1616

1717

1818
/**

test/ng/controllerSpec.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,27 @@ describe('$controller', function() {
9090
});
9191

9292

93-
it('should publish controller instance into scope', function() {
94-
var scope = {};
93+
describe('ctrl as syntax', function() {
9594

96-
$controllerProvider.register('FooCtrl', function() { this.mark = 'foo'; });
95+
it('should publish controller instance into scope', function() {
96+
var scope = {};
9797

98-
var foo = $controller('FooCtrl as foo', {$scope: scope});
99-
expect(scope.foo).toBe(foo);
100-
expect(scope.foo.mark).toBe('foo');
98+
$controllerProvider.register('FooCtrl', function() { this.mark = 'foo'; });
99+
100+
var foo = $controller('FooCtrl as foo', {$scope: scope});
101+
expect(scope.foo).toBe(foo);
102+
expect(scope.foo.mark).toBe('foo');
103+
});
104+
105+
106+
it('should allow controllers with dots', function() {
107+
var scope = {};
108+
109+
$controllerProvider.register('a.b.FooCtrl', function() { this.mark = 'foo'; });
110+
111+
var foo = $controller('a.b.FooCtrl as foo', {$scope: scope});
112+
expect(scope.foo).toBe(foo);
113+
expect(scope.foo.mark).toBe('foo');
114+
});
101115
});
102116
});

0 commit comments

Comments
 (0)