This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +21
-7
lines changed
2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 12
12
*/
13
13
function $ControllerProvider ( ) {
14
14
var controllers = { } ,
15
- CNTRL_REG = / ^ ( \w + ) ( \s + a s \s + ( \w + ) ) ? $ / ;
15
+ CNTRL_REG = / ^ ( \S + ) ( \s + a s \s + ( \w + ) ) ? $ / ;
16
16
17
17
18
18
/**
Original file line number Diff line number Diff line change @@ -90,13 +90,27 @@ describe('$controller', function() {
90
90
} ) ;
91
91
92
92
93
- it ( 'should publish controller instance into scope' , function ( ) {
94
- var scope = { } ;
93
+ describe ( 'ctrl as syntax' , function ( ) {
95
94
96
- $controllerProvider . register ( 'FooCtrl' , function ( ) { this . mark = 'foo' ; } ) ;
95
+ it ( 'should publish controller instance into scope' , function ( ) {
96
+ var scope = { } ;
97
97
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
+ } ) ;
101
115
} ) ;
102
116
} ) ;
You can’t perform that action at this time.
0 commit comments