This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ angular.module('ui.bootstrap.buttons', [])
14
14
return {
15
15
require : [ 'btnRadio' , 'ngModel' ] ,
16
16
controller : 'ButtonsController' ,
17
+ controllerAs : 'buttons' ,
17
18
link : function ( scope , element , attrs , ctrls ) {
18
19
var buttonsCtrl = ctrls [ 0 ] , ngModelCtrl = ctrls [ 1 ] ;
19
20
@@ -45,6 +46,7 @@ angular.module('ui.bootstrap.buttons', [])
45
46
return {
46
47
require : [ 'btnCheckbox' , 'ngModel' ] ,
47
48
controller : 'ButtonsController' ,
49
+ controllerAs : 'button' ,
48
50
link : function ( scope , element , attrs , ctrls ) {
49
51
var buttonsCtrl = ctrls [ 0 ] , ngModelCtrl = ctrls [ 1 ] ;
50
52
Original file line number Diff line number Diff line change @@ -16,6 +16,17 @@ describe('buttons', function () {
16
16
return el ;
17
17
} ;
18
18
19
+ it ( 'should expose the controller to the view' , inject ( function ( $templateCache ) {
20
+ var btn = compileButton ( '<button ng-model="model" btn-checkbox>{{button.text}}</button>' , $scope ) ;
21
+ var ctrl = btn . controller ( 'btnCheckbox' ) ;
22
+ expect ( ctrl ) . toBeDefined ( ) ;
23
+
24
+ ctrl . text = 'foo' ;
25
+ $scope . $digest ( ) ;
26
+
27
+ expect ( btn . html ( ) ) . toBe ( 'foo' ) ;
28
+ } ) ) ;
29
+
19
30
//model -> UI
20
31
it ( 'should work correctly with default model values' , function ( ) {
21
32
$scope . model = false ;
@@ -135,6 +146,17 @@ describe('buttons', function () {
135
146
return el . find ( 'button' ) ;
136
147
} ;
137
148
149
+ it ( 'should expose the controller to the view' , inject ( function ( $templateCache ) {
150
+ var btn = compileButtons ( '<button ng-model="model" btn-radio="1">{{buttons.text}}</button>' , $scope ) ;
151
+ var ctrl = btn . controller ( 'btnRadio' ) ;
152
+ expect ( ctrl ) . toBeDefined ( ) ;
153
+
154
+ ctrl . text = 'foo' ;
155
+ $scope . $digest ( ) ;
156
+
157
+ expect ( btn . html ( ) ) . toBe ( 'foo' ) ;
158
+ } ) ) ;
159
+
138
160
//model -> UI
139
161
it ( 'should work correctly set active class based on model' , function ( ) {
140
162
var btns = compileButtons ( '<button ng-model="model" btn-radio="1">click1</button><button ng-model="model" btn-radio="2">click2</button>' , $scope ) ;
You can’t perform that action at this time.
0 commit comments