javascript - angularjs想要操作ajax獲取到的數(shù)據(jù)總是報錯
問題描述
.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 == '未回復'){var temp = document.getElementById(tempdata.result[i].id);$(temp).children('#al_title').addClass('blackword');$(temp).children('#al_awswer').hide(); }} })})
代碼如上,這里我想比較獲取到的數(shù)據(jù)中的某幾項,但是瀏覽器測試一直報錯
求各位大神看看如何解決,剛接觸angular沒多久。。。。。。。。。。。。
問題解答
回答1:找到問題了,同事幫忙看了一下,是for里面寫錯了,應該是<寫成了<=…………習慣性從1開始循環(huán)這里從0開始就弄錯了_(:з」∠)_
回答2:console.log(tempdata.result); 輸出什么?。?/p>回答3:
這里說了報錯,去看看manageController 第133行
相關(guān)文章:
1. 在mac下出現(xiàn)了兩個docker環(huán)境2. 利用IPMI遠程安裝centos報錯!3. 運行python程序時出現(xiàn)“應用程序發(fā)生異?!钡膬?nèi)存錯誤?4. 測試自動化html元素選擇器元素ID或DataAttribute [關(guān)閉]5. spring-mvc - spring-session-redis HttpSessionListener失效6. 淺談Vue使用Cascader級聯(lián)選擇器數(shù)據(jù)回顯中的坑7. javascript - 在 model里定義的 引用表模型時,model為undefined。8. javascript - 最近用echarts做統(tǒng)計圖時遇到兩個問題!!9. mysql - 查詢 修改數(shù)據(jù)庫優(yōu)化問題吧10. java - Spring boot 讀取 放在 jar 包外的,log4j 配置文件,系統(tǒng)有創(chuàng)建日志文件,不寫入日志信息。

網(wǎng)公網(wǎng)安備