mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-21 04:41:51 +00:00
fix(ngController): allow dots in a controller name
The issue was introduced in cd38cbf975
This commit is contained in:
parent
cda7b71146
commit
de2cdb0658
2 changed files with 21 additions and 7 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
*/
|
*/
|
||||||
function $ControllerProvider() {
|
function $ControllerProvider() {
|
||||||
var controllers = {},
|
var controllers = {},
|
||||||
CNTRL_REG = /^(\w+)(\s+as\s+(\w+))?$/;
|
CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -90,13 +90,27 @@ describe('$controller', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should publish controller instance into scope', function() {
|
describe('ctrl as syntax', function() {
|
||||||
var scope = {};
|
|
||||||
|
|
||||||
$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});
|
$controllerProvider.register('FooCtrl', function() { this.mark = 'foo'; });
|
||||||
expect(scope.foo).toBe(foo);
|
|
||||||
expect(scope.foo.mark).toBe('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');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue