AngularJS UI-Bootstrap Datepicker在ng-repeat中不起作用?

时间:2016-11-14 06:23:22

标签: javascript angularjs angular-ui-bootstrap bootstrap-datepicker

我一直在尝试在ng-repeat中使用日期选择器但是datepicker在ng-repeat中不起作用,任何人都可以帮我解决这个问题。

这是我的代码,

 <div ng-repeat="dt in dates">
  <div class="col-md-6">
    <p class="input-group">
      <input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" />
      <span class="input-group-btn">
        <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
      </span>
    </p>
  </div>

1 个答案:

答案 0 :(得分:1)

检查此 DEMO

<h1>Datepicker inside repeater demo</h1>

<div class="container content-body">
<div class="row" ng-repeat="dt in dates">
    <div class="col-md-6">
        <p class="input-group">
          <input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="dt.date" is-open="dt.opened" datepicker-options="dateOptions" />
          <span class="input-group-btn">
            <button type="button" class="btn btn-default" ng-click="open($event,dt)"><i class="glyphicon glyphicon-calendar"></i></button>
          </span>
        </p>
    </div>
</div>