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

Commit

Permalink
fix(timepicker): evaluate correctly the readonly-input attribute
Browse files Browse the repository at this point in the history
Closes #1911
  • Loading branch information
bekos committed Mar 8, 2014
1 parent f715d05 commit f9b6c49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/timepicker/test/timepicker.spec.js
Expand Up @@ -601,6 +601,20 @@ describe('timepicker directive', function () {
});
});

describe('`readonly-input` attribute', function() {
beforeEach(inject(function() {
$rootScope.meridiansArray = ['am', 'pm'];
element = $compile('<timepicker ng-model="time" readonly-input="true"></timepicker>')($rootScope);
$rootScope.$digest();
}));

it('should make inputs readonly', function () {
var inputs = element.find('input');
expect(inputs.eq(0).attr('readonly')).toBe('readonly');
expect(inputs.eq(1).attr('readonly')).toBe('readonly');
});
});

describe('setting timepickerConfig steps', function() {
var originalConfig = {};
beforeEach(inject(function(_$compile_, _$rootScope_, timepickerConfig) {
Expand Down
4 changes: 2 additions & 2 deletions src/timepicker/timepicker.js
Expand Up @@ -26,7 +26,7 @@ angular.module('ui.bootstrap.timepicker', [])
this.setupMousewheelEvents( hoursInputEl, minutesInputEl );
}

$scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
$scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
this.setupInputEvents( hoursInputEl, minutesInputEl );
};

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

if ( ngModelCtrl ) {
Expand Down

0 comments on commit f9b6c49

Please sign in to comment.