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

Commit

Permalink
fix(buttons): re-expose ButtonsController
Browse files Browse the repository at this point in the history
- Re-expose `ButtonsController` with deprecation message

Closes #4526
  • Loading branch information
wesleycho committed Oct 3, 2015
1 parent f561aa9 commit c0dbf79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/buttons/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,18 @@ angular.module('ui.bootstrap.buttons')

.value('$buttonsSuppressWarning', false)

.controller('ButtonsController', ['$controller', '$log', '$buttonsSuppressWarning', function($controller, $log, $buttonsSuppressWarning) {
if (!$buttonsSuppressWarning) {
$log.warn('ButtonsController is now deprecated. Use UibButtonsController instead.');
}

angular.extend(this, $controller('UibButtonsController'));
}])

.directive('btnRadio', ['$log', '$buttonsSuppressWarning', function($log, $buttonsSuppressWarning) {
return {
require: ['btnRadio', 'ngModel'],
controller: 'UibButtonsController',
controller: 'ButtonsController',
controllerAs: 'buttons',
link: function(scope, element, attrs, ctrls) {
if (!$buttonsSuppressWarning) {
Expand Down Expand Up @@ -145,7 +153,7 @@ angular.module('ui.bootstrap.buttons')
.directive('btnCheckbox', ['$document', '$log', '$buttonsSuppressWarning', function($document, $log, $buttonsSuppressWarning) {
return {
require: ['btnCheckbox', 'ngModel'],
controller: 'UibButtonsController',
controller: 'ButtonsController',
controllerAs: 'button',
link: function(scope, element, attrs, ctrls) {
if (!$buttonsSuppressWarning) {
Expand Down
11 changes: 7 additions & 4 deletions src/buttons/test/buttons.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,12 @@ describe('buttons deprecation', function() {
element = $compile('<button ng-model="model" btn-radio="1">click1</button><button ng-model="model" btn-radio="2">click2</button>')($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(3);
expect($log.warn.calls.argsFor(0)).toEqual(['btn-checkbox is now deprecated. Use uib-btn-checkbox instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
expect($log.warn.calls.argsFor(2)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
expect($log.warn.calls.count()).toBe(6);
expect($log.warn.calls.argsFor(0)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['btn-checkbox is now deprecated. Use uib-btn-checkbox instead.']);
expect($log.warn.calls.argsFor(2)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']);
expect($log.warn.calls.argsFor(3)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
expect($log.warn.calls.argsFor(4)).toEqual(['ButtonsController is now deprecated. Use UibButtonsController instead.']);
expect($log.warn.calls.argsFor(5)).toEqual(['btn-radio is now deprecated. Use uib-btn-radio instead.']);
}));
});

0 comments on commit c0dbf79

Please sign in to comment.