私は固執していて、このコードをどのように処理するのか分かりません。私は要件に応じてhtmlを変更しましたが、Ajaxレスポンスの後、Angula Jsのオブジェクト値を再初期化することはできません。誰でも助けてもらえれば、私は彼に感謝します。html ng-repeatオブジェクトごとにAngularJsオブジェクトをr-初期化できませんか?
<div ng-repeat="(key,sch) in classSchedule">
<h2>{{sch.sectionName}}</h2>
<table class="table table-bordered table-hover" >
<tbody>
<tr>
<th style="width: 10px">{{phrase.Day}}</th>
<th>{{phrase.ClassSchedule}}</th>
<th ng-if="userRole == 'admin'" style="width: 10px">Add</th>
</tr>
<tr ng-repeat="subSch in sch.schedule">
<td>{{subSch.dayName}}</td>
<td>
<div class="btn-group" ng-repeat="subSubSch in subSch.sub">
<button type="button" class="btn btn-default">{{subSubSch.subjectId}} - {{subSubSch.start}} -> {{subSubSch.end}}</button>
<button ng-if="userRole == 'admin'" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">{{phrase.toggleDropdown}}</span>
</button>
<ul ng-if="userRole == 'admin'" class="dropdown-menu" role="menu">
<li><a ng-click="editSubOne(subSubSch.id,key)">{{phrase.Edit}}</a></li>
<li><a ng-click="removeSub(subSubSch.id,key)">{{phrase.Remove}}</a></li>
</ul>
</div>
</td>
<td ng-if="userRole == 'admin'">
<a ng-click="addSubOne(key)" type="button" class="btn btn-info btn-flat"><i class="fa fa-fw fa-plus"></i></a>
</td>
</tr>
</tbody>
</table>
</div>
<script>
$scope.saveEditSub = function(id){
showHideLoad();
dataFactory.httpRequest('classschedule/sub/'+id,'POST',{},$scope.form).then(function(data) {
response = apiResponse(data,'edit');
if(data.status == "success"){
for (x in $scope.classSchedule[$scope.oldDay].schedule.sub) {
if($scope.classSchedule[$scope.oldDay].schedule.sub[x].id == id){
$scope.classSchedule[$scope.oldDay].schedule.sub.splice(x,1);
}
}
if(! $scope.classSchedule[response.dayOfWeek].schedule.sub){
$scope.classSchedule[response.dayOfWeek].schedule.sub = [];
}
$scope.classSchedule[response.dayOfWeek].schedule.sub.push({"id":response.id,"classId":response.classId,"subjectId":response.subjectId,"start":response.startTime,"end":response.endTime});
}
$scope.scheduleModalEdit = !$scope.scheduleModalEdit;
showHideLoad(true);
});
</script>
AJAX呼び出しの後
エラー: - > $ scope.classSchedule [response.dayOfWeek]応答を待っている
おかげ&定義されていません。
を?変数を変更すると、HTMLが変更に従います。 –
実際に私の要求に応じてhtmlを変更しましたが、ajax呼び出し後にエラーを返すためjsを変更できません。エラーが発生しています –