diff --git a/src/buttons/buttons.js b/src/buttons/buttons.js index dc4dddcd8e..b601da60ca 100644 --- a/src/buttons/buttons.js +++ b/src/buttons/buttons.js @@ -14,6 +14,7 @@ angular.module('ui.bootstrap.buttons', []) return { require: ['btnRadio', 'ngModel'], controller: 'ButtonsController', + controllerAs: 'buttons', link: function (scope, element, attrs, ctrls) { var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1]; @@ -45,6 +46,7 @@ angular.module('ui.bootstrap.buttons', []) return { require: ['btnCheckbox', 'ngModel'], controller: 'ButtonsController', + controllerAs: 'button', link: function (scope, element, attrs, ctrls) { var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1]; diff --git a/src/buttons/test/buttons.spec.js b/src/buttons/test/buttons.spec.js index 70b5513563..327bb1ef3b 100644 --- a/src/buttons/test/buttons.spec.js +++ b/src/buttons/test/buttons.spec.js @@ -16,6 +16,17 @@ describe('buttons', function () { return el; }; + it('should expose the controller to the view', inject(function ($templateCache) { + var btn = compileButton('', $scope); + var ctrl = btn.controller('btnCheckbox'); + expect(ctrl).toBeDefined(); + + ctrl.text = 'foo'; + $scope.$digest(); + + expect(btn.html()).toBe('foo'); + })); + //model -> UI it('should work correctly with default model values', function () { $scope.model = false; @@ -135,6 +146,17 @@ describe('buttons', function () { return el.find('button'); }; + it('should expose the controller to the view', inject(function ($templateCache) { + var btn = compileButtons('', $scope); + var ctrl = btn.controller('btnRadio'); + expect(ctrl).toBeDefined(); + + ctrl.text = 'foo'; + $scope.$digest(); + + expect(btn.html()).toBe('foo'); + })); + //model -> UI it('should work correctly set active class based on model', function () { var btns = compileButtons('', $scope);