Javascript Angular js指令在for循环中不起作用
我使用的是Diactive in ng repeat,当我单击时,我会将日期和时间传递给函数showAppointmentForm,但这里的问题是当我单击循环的第一个索引时,我会在模式框中显示日期和时间,但当我单击第二个时,第三,等等,它的值是作为函数参数来的,但不显示。在for循环中使用指令是否有问题。请任何人提供帮助。谢谢 在模板中使用指令Javascript Angular js指令在for循环中不起作用,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我使用的是Diactive in ng repeat,当我单击时,我会将日期和时间传递给函数showAppointmentForm,但这里的问题是当我单击循环的第一个索引时,我会在模式框中显示日期和时间,但当我单击第二个时,第三,等等,它的值是作为函数参数来的,但不显示。在for循环中使用指令是否有问题。请任何人提供帮助。谢谢 在模板中使用指令 <div data-ng-repeat="doctor in doctors"> <appointment-timings
<div data-ng-repeat="doctor in doctors">
<appointment-timings data-ng-if="appointments" appointments="appointments" physician="doctor.npi" width="2"></appointment-timings>
</div>
我的指令html(模式框)
日期
时间
- {{time}
你能打个电话吗?我看不到对ShowAppointForm的呼叫@Dmitry,我编辑了我的代码。日期对象是什么?可能是未定义
。如果是这样的话,showAppointmentForm
函数将在date.toString()
上失败,AngularJS只是悄悄地掉了下来。我遇到了时间问题。你能做个plnkrI吗?我看不到调用showAppointmentForm
@Dmitry,我编辑了我的代码。date
对象是什么?可能是未定义
。如果是这样的话,showAppointmentForm
函数将在date.toString()
失败,AngularJS只是静静地掉了下来,我遇到了时间问题。
$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);
}
<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>