fix(ngController): allow dots in a controller name

The issue was introduced in cd38cbf975
This commit is contained in:
Vojta Jina 2013-04-30 11:47:23 -07:00
parent cda7b71146
commit de2cdb0658
2 changed files with 21 additions and 7 deletions

View file

@ -12,7 +12,7 @@
*/
function $ControllerProvider() {
var controllers = {},
CNTRL_REG = /^(\w+)(\s+as\s+(\w+))?$/;
CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/;
/**

View file

@ -90,13 +90,27 @@ describe('$controller', function() {
});
it('should publish controller instance into scope', function() {
var scope = {};
describe('ctrl as syntax', function() {
$controllerProvider.register('FooCtrl', function() { this.mark = 'foo'; });
it('should publish controller instance into scope', function() {
var scope = {};
var foo = $controller('FooCtrl as foo', {$scope: scope});
expect(scope.foo).toBe(foo);
expect(scope.foo.mark).toBe('foo');
$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');
});
it('should allow controllers with dots', function() {
var scope = {};
$controllerProvider.register('a.b.FooCtrl', function() { this.mark = 'foo'; });
var foo = $controller('a.b.FooCtrl as foo', {$scope: scope});
expect(scope.foo).toBe(foo);
expect(scope.foo.mark).toBe('foo');
});
});
});