Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit c0dbf79

Browse files
committed
fix(buttons): re-expose ButtonsController
- Re-expose `ButtonsController` with deprecation message Closes #4526
1 parent f561aa9 commit c0dbf79

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/buttons/buttons.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,18 @@ angular.module('ui.bootstrap.buttons')
104104

105105
.value('$buttonsSuppressWarning', false)
106106

107+
.controller('ButtonsController', ['$controller', '$log', '$buttonsSuppressWarning', function($controller, $log, $buttonsSuppressWarning) {
108+
if (!$buttonsSuppressWarning) {
109+
$log.warn('ButtonsController is now deprecated. Use UibButtonsController instead.');
110+
}
111+
112+
angular.extend(this, $controller('UibButtonsController'));
113+
}])
114+
107115
.directive('btnRadio', ['$log', '$buttonsSuppressWarning', function($log, $buttonsSuppressWarning) {
108116
return {
109117
require: ['btnRadio', 'ngModel'],
110-
controller: 'UibButtonsController',
118+
controller: 'ButtonsController',
111119
controllerAs: 'buttons',
112120
link: function(scope, element, attrs, ctrls) {
113121
if (!$buttonsSuppressWarning) {
@@ -145,7 +153,7 @@ angular.module('ui.bootstrap.buttons')
145153
.directive('btnCheckbox', ['$document', '$log', '$buttonsSuppressWarning', function($document, $log, $buttonsSuppressWarning) {
146154
return {
147155
require: ['btnCheckbox', 'ngModel'],
148-
controller: 'UibButtonsController',
156+
controller: 'ButtonsController',
149157
controllerAs: 'button',
150158
link: function(scope, element, attrs, ctrls) {
151159
if (!$buttonsSuppressWarning) {

src/buttons/test/buttons.spec.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,12 @@ describe('buttons deprecation', function() {
371371
element = $compile('<button ng-model="model" btn-radio="1">click1</button><button ng-model="model" btn-radio="2">click2</button>')($rootScope);
372372
$rootScope.$digest();
373373

374-
expect($log.warn.calls.count()).toBe(3);
375-
expect($log.warn.calls.argsFor(0)).toEqual(['btn-checkbox is now deprecated. Use uib-btn-checkbox instead.']);
376-
expect($log.warn.calls.argsFor(1)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
377-
expect($log.warn.calls.argsFor(2)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
374+
expect($log.warn.calls.count()).toBe(6);
375+
expect($log.warn.calls.argsFor(0)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']);
376+
expect($log.warn.calls.argsFor(1)).toEqual(['btn-checkbox is now deprecated. Use uib-btn-checkbox instead.']);
377+
expect($log.warn.calls.argsFor(2)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']);
378+
expect($log.warn.calls.argsFor(3)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
379+
expect($log.warn.calls.argsFor(4)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']);
380+
expect($log.warn.calls.argsFor(5)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
378381
}));
379382
});

0 commit comments

Comments
 (0)