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

Commit

Permalink
fix(timepicker): re-expose TimepickerController
Browse files Browse the repository at this point in the history
- Re-expose `TimepickerController` with deprecation notice

Closes #4531
  • Loading branch information
wesleycho committed Oct 3, 2015
1 parent 435924f commit 3aa9841
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/timepicker/test/timepicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,8 @@ describe('timepicker deprecation', function() {
element = $compile(element)($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(1);
expect($log.warn.calls.argsFor(0)).toEqual(['timepicker is now deprecated. Use uib-timepicker instead.']);
expect($log.warn.calls.count()).toBe(2);
expect($log.warn.calls.argsFor(0)).toEqual(['TimepickerController is now deprecated. Use UibTimepickerController instead.']);
expect($log.warn.calls.argsFor(1)).toEqual(['timepicker is now deprecated. Use uib-timepicker instead.']);
}));
});
13 changes: 12 additions & 1 deletion src/timepicker/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,22 @@ angular.module('ui.bootstrap.timepicker')

.value('$timepickerSuppressWarning', false)

.controller('TimepickerController', ['$scope', '$attrs', '$controller', '$log', '$timepickerSuppressWarning', function($scope, $attrs, $controller, $log, $timepickerSuppressWarning) {
if (!$timepickerSuppressWarning) {
$log.warn('TimepickerController is now deprecated. Use UibTimepickerController instead.');
}

angular.extend(this, $controller('UibTimepickerController', {
$scope: $scope,
$attrs: $attrs
}));
}])

.directive('timepicker', ['$log', '$timepickerSuppressWarning', function($log, $timepickerSuppressWarning) {
return {
restrict: 'EA',
require: ['timepicker', '?^ngModel'],
controller: 'UibTimepickerController',
controller: 'TimepickerController',
controllerAs: 'timepicker',
replace: true,
scope: {},
Expand Down

0 comments on commit 3aa9841

Please sign in to comment.