javascript - angularjs想要操作ajax獲取到的數(shù)據(jù)總是報(bào)錯
問題描述
.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),但是瀏覽器測試一直報(bào)錯
求各位大神看看如何解決,剛接觸angular沒多久。。。。。。。。。。。。
問題解答
回答1:找到問題了,同事幫忙看了一下,是for里面寫錯了,應(yīng)該是<寫成了<=…………習(xí)慣性從1開始循環(huán)這里從0開始就弄錯了_(:з」∠)_
回答2:console.log(tempdata.result); 輸出什么啊?
回答3:這里說了報(bào)錯,去看看manageController 第133行
相關(guān)文章:
1. git - 使用淘寶npm安裝hexo出現(xiàn)問題?2. html5和Flash對抗是什么情況?3. 小程序怎么加外鏈,語句怎么寫!求救新手,開文檔沒發(fā)現(xiàn)4. javascript - vue-resource中如何設(shè)置全局的timeout?5. javascript - 在 vue里面用import引入js文件,結(jié)果為undefined6. PC 手機(jī)兼容的 編輯器7. php如何獲取訪問者路由器的mac地址8. 多選框?qū)戇M(jìn)數(shù)據(jù)庫怎么寫9. 求教一個mysql建表分組索引問題10. thinkPHP5中獲取數(shù)據(jù)庫數(shù)據(jù)后默認(rèn)選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙
