katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
169 stars 101 forks source link

Setting a range for the Hours. E.g. can only select from 0900 to 2100 (9AM-9PM) #35

Open asterzwx opened 8 years ago

asterzwx commented 8 years ago

Able to let user select only the hours in the Day? for example, they can only choose from 0900 - 2100 (9AM - 9PM), so hours from 2200 - 0800 is not allowed. Do I need to change anything in the plugin file? Thank you.

katemihalikova commented 8 years ago

Current version supports just simple use-cases, your one is planned for next major release. As a workaround, you can add a validator that validates the time. ion-datetime-picker runs ng-model under the hood so everything you would use with <input> applies there as well.

asterzwx commented 8 years ago

Hi thanks for your reply. Currently I'm using ion-datetime-picker instead of input, so will I still be able to proceed with my use case? If so, do I just validate the time from the controller itself? I would also need to set the min Hour and max Hour, can I do that in the controller?

katemihalikova commented 8 years ago

ion-datetime-picker and <input type="date/time/datetime-local"> should be equal from the controller's point of view. You can either make up the validator in the controller itself or use a custom ng-model validator if you are already using build-in form validations.

asterzwx commented 8 years ago

I see. By the way, I need to modify the hour (as shown in attached photo), and I can only do so in ion-datetime-picker.min.js using e.hour. How will I be able to access this from the controller? Much thanks.

timehr

katemihalikova commented 8 years ago

You can change the model value itself to do this.

asterzwx commented 8 years ago

Alright I'll try doing that. Thank you :)

asterzwx commented 8 years ago

Oh yes, sorry one more thing, are we able to let the hour and minute boxes in the popup to be non-editable? Update: I managed to do that using ng-readonly="true".

katemihalikova commented 8 years ago

Of course not, if you want to set date only, use date picker without the time part. But if you are ok with changing the plugin, feel free to tailor it to your needs :)

asterzwx commented 8 years ago

Alright thanks again :+1:

WangShayne commented 7 years ago

I set the time value $rootScope.startTimeValue = 0; and it's look like '08:00',but when i click this item,input change the time becomes the current time '10:14',How to modify the default time of input? thanks :+1:

katemihalikova commented 7 years ago

Hi Wang, it seems like you are in a wrong issue. Your problem is discussed in #19 and #2. If you are still unable to make it work, feel free to open new issue with a codepen/plnkr/jsbin demonstrating the problem.