javascript - angularjs想要操作ajax獲取到的數(shù)據(jù)總是報(bào)錯(cuò)
問(wèn)題描述
.controller(’alistcontrol’,function($scope, aliService){ $scope.advlist = { id: '', status : '', content : '', qTime : '', answer : '', aTime : '',} aliService.getlis().then(function(data){var tempdata = angular.fromJson(data);$scope.advlist = tempdata.result;$scope.$watch(’advlist’,function(newValue){ if(!newValue){$('.al_nonedis').show(); }});console.log(tempdata.result);for(var i = 0;i<=tempdata.result.length;i++){ console.log(tempdata.result[i].status); if(tempdata.result[i].status == '未回復(fù)'){var temp = document.getElementById(tempdata.result[i].id);$(temp).children('#al_title').addClass('blackword');$(temp).children('#al_awswer').hide(); }} })})
代碼如上,這里我想比較獲取到的數(shù)據(jù)中的某幾項(xiàng),但是瀏覽器測(cè)試一直報(bào)錯(cuò)
求各位大神看看如何解決,剛接觸angular沒(méi)多久。。。。。。。。。。。。
問(wèn)題解答
回答1:找到問(wèn)題了,同事幫忙看了一下,是for里面寫(xiě)錯(cuò)了,應(yīng)該是<寫(xiě)成了<=…………習(xí)慣性從1開(kāi)始循環(huán)這里從0開(kāi)始就弄錯(cuò)了_(:з」∠)_
回答2:console.log(tempdata.result); 輸出什么啊?
回答3:這里說(shuō)了報(bào)錯(cuò),去看看manageController 第133行
相關(guān)文章:
1. node.js - mysql如何通過(guò)knex查詢今天和七天內(nèi)的匯總數(shù)據(jù)2. mysql 插入數(shù)值到特定的列一直失敗3. 360瀏覽器與IE瀏覽器有何區(qū)別???4. Python從URL中提取域名5. mysql - 百萬(wàn)行的表中是否盡量避免使用update等sql語(yǔ)句?6. python - 在使用Pycharm時(shí)經(jīng)常看到如下的樣式,小括號(hào)里紅色的部分是什么意思呢?7. javascript - 新浪微博網(wǎng)頁(yè)版的字?jǐn)?shù)限制是怎么做的8. 怎么在網(wǎng)頁(yè)中設(shè)置圖片進(jìn)行左右滑動(dòng)9. javascript - 豆瓣的這個(gè)自適應(yīng)是怎么做的?10. javascript - 用jsonp抓取qq音樂(lè)總是說(shuō)回調(diào)函數(shù)沒(méi)有定義
