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

Commit

Permalink
fix(ngController): allow dots in a controller name
Browse files Browse the repository at this point in the history
The issue was introduced in cd38cbf
  • Loading branch information
vojtajina committed Apr 30, 2013
1 parent cda7b71 commit de2cdb0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ng/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
function $ControllerProvider() {
var controllers = {},
CNTRL_REG = /^(\w+)(\s+as\s+(\w+))?$/;
CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/;


/**
Expand Down
26 changes: 20 additions & 6 deletions test/ng/controllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});

0 comments on commit de2cdb0

Please sign in to comment.