File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 */
1313function $ControllerProvider ( ) {
1414 var controllers = { } ,
15- CNTRL_REG = / ^ ( \w + ) ( \s + a s \s + ( \w + ) ) ? $ / ;
15+ CNTRL_REG = / ^ ( \S + ) ( \s + a s \s + ( \w + ) ) ? $ / ;
1616
1717
1818 /**
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments