I'm using Angular UI Bootstrap datepicker with the gm.datepickerMultiSelect extension and I'd like to make weekdays labels clickable, so that I could select all days in the month (like all Wednesdays). I can get/calculate all days of the same weekday and add them to the selected days scope, but as I'm rather new to AngularJS & Bootstrap UI, I can't find the right way to trigger that click event for the labels.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Angular UI Bootstrap lets you override their directive's templates. You can create your own template by putting it inside a
<script>
tag with typetext/ng-template
.So we copy the contents of Angular UI's
template/datepicker/day.html
and we alter it a little bit to call a new functionselectWeekday
on our weekday'sng-click
:Note: This script tag must be within your
ng-app
or else it will be ignored and won't overwrite the original template.Now we need to modify the
datepicker
directive with AngularJS decorators to add theselectWeekday
function:And from the controller listen to
datepicker.selectWeekday
:From here you can add the logic to select the days based on the known selected weekday!
Here's a working plunkr: http://plnkr.co/edit/Ef4gd7SUYMcG05PuvqFh?p=preview