Ionic-Calendar
Ionic-Calendar copied to clipboard
disabled dates
Is there a way to add disabled date ? So user can't click on it , like weekends
@hamad251 To show the dates as disabled, for example, using grey background requires some code change. If you just want to do nothing when the dates at the weekends are clicked, you can add some check in the timeSelected callback.
@hamad251 I have added view customisation support in version 0.3.0. Mark the weekends using different background color is also supported.
Mark the weekends using different background color is also supported.
how? I can't find any documentation about it....tnx It would be useful even extends this logic to an array of dates (such as Christmas day and another holiday in the year...)
@bartsimp Check the view customization option section in README. You can pass your own template and add whatever binding logic you want. For example, you can add a new field in the event to indicate holidays, and change the color based on that field.
@twinssbc trying to follow your suggestion, if I have more events on that day and only one of them tells me that that day is holiday, how do I scroll through the list of events to find an event marked as a holiday? I tried declaring a function similar to yours getHighlightClass () but I had to put it into the calendar-tpls.js file. there is a way to not alter your source? thank you
this is my custom template
<div ng-class="getMyClass(view.dates[row*7+col])">{{view.dates[row*7+col].label}}</div>
and this is the new function
scope.getMyClass = function(date) {
var className = '';
if (date.hasEvent) {
var i = 0;
var done = false;
while (i<date.events.length && !done) {
if (date.events[i].isHoliday) {
done = true;
className += 'text-muted';
}
i++;
}
}
return className;
}
@bartsimp Yes, it seems the source code has to be modified to achieve your requirement. I will expose some option to allow passing in a list of holiday dates in a future version.
I was going to open a new issue but decided that this is close enough to my problem to ask here... Is there any way to access my controller from inside the custom template?
I've tried using $parent, but with no success... Also, in case there is no way today, do you know what steps to make this possible (just point me in the right direction), I can try to solve this and send a PR
@josecostamartins I haven't figured out how to directly use $parent to access your own controller. The only connection between the custom template and the scope in your own controller is the events passed to the calendar. I'm thinking maybe you can add fields and methods to the events object, and then use them in the custom template?
I added isDateDisabled callback to support disabled dates.