I have a
$scope.reasonList
which I iterate with ng-repeat
. But if I go back and forward exactly same page with same data sometimes if
operatotor is not working and the $scope.reasonList
is empty. Exactly same data and same page? Those are strings what I have been comparing. What is happening here and WHY?
var reasons = new Array();
var roots = new Array();
var repairs = new Array();
var defectDescsArray = new Array();
defectDescsArray= defectDescSvc.query();
$scope.rma = rmaService.get({id: $routeParams.rmaId});
var rmaHasDefects = rmaDefectSvc.findByRmaId({rmaid: $routeParams.rmaId});
rmaHasDefects.$promise.then(function (result) {
alert('result.length:' +result.length)
for (var i = 0; i < result.length; i++) {
for (var j = 0; j < defectDescsArray.length; j++) {
if (result[i].rmaHasDefectdescPK.defectdescDefectdescId === defectDescsArray[j].defectdescId) {
$scope.showReasonList = true;
reasons.push(defectDescsArray[j]);
}
}
}
$scope.reasonList = reasons;
//$scope.$apply();
alert('$scope.reasonList.length' +$scope.reasonList.length);
});
VIEW
<div class="col-sm-10">
<table class="table table-striped table-condensed table-hover">
<tbody>
<tr ng-repeat="defect in reasonList">
<td>{{ defect.returnreasonReturnreasonId.returnText}}</td>
<td>{{ defect.text}}</td>
</TR>
</TBODY>
</table>
</div>
Angular Service for getting defects
angular.module('defectDescService', ['ngResource'])
.factory('defectDescSvc', ['$resource',
function ($resource) {
console.log('------defectDescService-----');
return $resource(
'/RMAServerMav/webresources/com.rako.entity.defectdesc/:id',
{},
{
delete: { method: 'DELETE', params: {id: '@defectdescId'}},
update: { method: 'PUT', params: {id: '@defectdescId'} },
findByDefectdescId:{
url: '/RMAServerMav/webresources/com.rako.entity.defectdesc/defect/:defid',
method: 'GET',
params: {defid: '@defid'},
isArray:true}
});
}]);