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

fix(timepicker): re-expose TimepickerController #4531

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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