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里面寫錯了,應(yīng)該是<寫成了<=…………習慣性從1開始循環(huán)這里從0開始就弄錯了_(:з」∠)_
回答2:console.log(tempdata.result); 輸出什么???
回答3:這里說了報錯,去看看manageController 第133行
相關(guān)文章:
1. node.js - mongoDB使用$gte的問題2. android - 優(yōu)酷的安卓及蘋果app還在使用flash技術(shù)嗎?3. android 微信是如何實現(xiàn)即時更新好友頭像的4. 黑客 - Python模塊安全權(quán)限5. android - 像支付寶到位這種點擊marker點擊變大怎么做的6. html5 - H5頁面喚起APP導航7. docker - 如何修改運行中容器的配置8. angular.js - ngview配置路由失敗9. javascript - 關(guān)于vuejs讀取數(shù)據(jù)的問題10. javascript - 可以左右滑動的導航菜單怎么實現(xiàn)
