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里面寫錯(cuò)了,應(yīng)該是<寫成了<=…………習(xí)慣性從1開始循環(huán)這里從0開始就弄錯(cuò)了_(:з」∠)_
回答2:console.log(tempdata.result); 輸出什么啊?
回答3:這里說(shuō)了報(bào)錯(cuò),去看看manageController 第133行
相關(guān)文章:
1. python - 獲取到的數(shù)據(jù)生成新的mysql表2. 為什么python中實(shí)例檢查推薦使用isinstance而不是type?3. mysql里的大表用mycat做水平拆分,是不是要先手動(dòng)分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現(xiàn) 4046. python - (初學(xué)者)代碼運(yùn)行不起來(lái),求指導(dǎo),謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無(wú)法觸發(fā)9. python的文件讀寫問(wèn)題?10. javascript - js 對(duì)中文進(jìn)行MD5加密和python結(jié)果不一樣。
