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

Commit f9b6c49

Browse files
committed
fix(timepicker): evaluate correctly the readonly-input attribute
Closes #1911
1 parent f715d05 commit f9b6c49

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/timepicker/test/timepicker.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,20 @@ describe('timepicker directive', function () {
601601
});
602602
});
603603

604+
describe('`readonly-input` attribute', function() {
605+
beforeEach(inject(function() {
606+
$rootScope.meridiansArray = ['am', 'pm'];
607+
element = $compile('<timepicker ng-model="time" readonly-input="true"></timepicker>')($rootScope);
608+
$rootScope.$digest();
609+
}));
610+
611+
it('should make inputs readonly', function () {
612+
var inputs = element.find('input');
613+
expect(inputs.eq(0).attr('readonly')).toBe('readonly');
614+
expect(inputs.eq(1).attr('readonly')).toBe('readonly');
615+
});
616+
});
617+
604618
describe('setting timepickerConfig steps', function() {
605619
var originalConfig = {};
606620
beforeEach(inject(function(_$compile_, _$rootScope_, timepickerConfig) {

src/timepicker/timepicker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ angular.module('ui.bootstrap.timepicker', [])
2626
this.setupMousewheelEvents( hoursInputEl, minutesInputEl );
2727
}
2828

29-
$scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
29+
$scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
3030
this.setupInputEvents( hoursInputEl, minutesInputEl );
3131
};
3232

@@ -243,7 +243,7 @@ angular.module('ui.bootstrap.timepicker', [])
243243
replace: true,
244244
scope: {},
245245
templateUrl: 'template/timepicker/timepicker.html',
246-
link: function(sscope, element, attrs, ctrls) {
246+
link: function(scope, element, attrs, ctrls) {
247247
var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
248248

249249
if ( ngModelCtrl ) {

0 commit comments

Comments
 (0)