Angular UI Bootstrap DatePicker - 在关闭/模糊时获取所选日期

Hol*_*ley 19 angularjs angular-ui-bootstrap

我有一个ng-repeat,每行都有多个UI-Bootstrap Datepickers.当选择日期并且选择器关闭时,我试图在我的控制器中调用一个函数.我已经尝试使用UI-Event来捕获模糊事件,但是当调用它时模型尚未更新.我的问题是如何在选择器关闭时获得所选日期?我可以做类似的事情ui-event="{ blur : 'myBlurFunction( $event, this.text)' },还是有另一种方法来获取onClose事件的数据?

<li ng-repeat="....">
   <div ng-click="openEditStartCal($event, ticket)">
                <input ui-event="{ blur : 'blurredStartDate( $event, ticket, this.text)' }" 
                       type="text" 
                       starting-day="2" 
                       show-button-bar="false" 
                       show-weeks="false" 
                       class="form-control addTicketDateInput" 
                       datepicker-popup="dd MMM" 
                       ng-model="ticket.StartDate" 
                       is-open="startEditTicketOpened && currentTicketUpdating == ticket.TicketId" 
                       min-date="{{today()}}" 
                       max-date="'2015-06-22'" 
                       datepicker-options="dateOptions" 
                       date-disabled="disabled(date, mode)"  
                       ng-required="true" close-text="Close" />
   </div>
Run Code Online (Sandbox Code Playgroud)

Hol*_*ley 33

我用以下方法解决了这个问题: ng-change="myChangeFunction()".


Rid*_*hil 7

这可以使用ng-change :

html/jsp文件

 <input type="text" 
    id="StartDate" 
    name="StartDate"  
    class="form-control input-sm" 
    uib-datepicker-popup="{{format}}" 
    ng-model="StartDateVal" 
    is-open="status.opened" 
    min-date="min" 
    max-date="max"
    datepicker-options="dateOptions" 
    date-disabled="disabled(date, mode)" 
    ng-required="true"
    close-text="Close" 
    readonly="true" 
    ng-change="select(StartDateVal)" />
Run Code Online (Sandbox Code Playgroud)

.js控制器

$scope.select = function(date) { 
      // here you will get updated date
};
Run Code Online (Sandbox Code Playgroud)