Angular js指令不适用于for循环

时间:2017-08-02 08:59:42

标签: javascript angularjs angularjs-directive

我正在使用ng-repeat中的死亡,当我点击我将日期和时间传递给函数showAppointmentForm但这里问题是当我点击循环的第一个索引时我得到日期和时间显示在模态框中但是当我点击第二个,第三个,依此类推,它的值将作为函数参数出现,但不会显示。这就是在for循环中使用指令的问题。任何人都可以建议帮助。谢谢。

在模板中使用指令

 <div data-ng-repeat="doctor in doctors">  
  <appointment-timings data-ng-if="appointments" appointments="appointments" physician="doctor.npi"  width="2"></appointment-timings>

 </div>

我的指定,

  $scope.showAppointmentForm = function(date,time) {
    $scope.appointmentData = {};
    $scope.appointmentData.physician = $scope.physician;
    $scope.appointmentData.date = '';
    $scope.appointmentData.time = '';
    $scope.appointmentData.date = date.toString();
    $scope.appointmentData.time = time;
    $scope.submitted = false;
    $timeout(function () {
      $scope.$apply();
      $('#appointments').modal('show');
    },500);
  }

My Directive html,(模态框)

<div class="date-time">
        <div class="col-md-6 col-xs-6">
          <div class="input-group">
            <span class="input-group-addon"><b>DATE</b></span>
            <input type="text" class="form-control"  ng-model="appointmentData.date" disabled>
          </div><!-- /input-group -->
        </div>
        <div class="col-md-6 col-xs-6">
          <div class="input-group">
            <span class="input-group-addon"><b>TIME</b></span>
            <input type="text" class="form-control" ng-model="appointmentData.time" disabled>
          </div>
        </div>
      </div>
     <div class="scheduled-hours" id="scheduled-scroll">
<ul>
  <li data-ng-click="showAppointmentForm(date, time)" data-ng-repeat="time in times">{{time}}</li>
</ul>

 </div>

0 个答案:

没有答案