javascript - angularjs想要操作ajax獲取到的數(shù)據(jù)總是報(bào)錯(cuò)
問題描述
.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)錯(cuò)
求各位大神看看如何解決,剛接觸angular沒多久。。。。。。。。。。。。
問題解答
回答1:找到問題了,同事幫忙看了一下,是for里面寫錯(cuò)了,應(yīng)該是<寫成了<=…………習(xí)慣性從1開始循環(huán)這里從0開始就弄錯(cuò)了_(:з」∠)_
回答2:console.log(tempdata.result); 輸出什么啊?
回答3:這里說了報(bào)錯(cuò),去看看manageController 第133行
相關(guān)文章:
1. boot2docker無法啟動(dòng)2. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””3. docker-compose中volumes的問題4. nignx - docker內(nèi)nginx 80端口被占用5. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.6. java - SSH框架中寫分頁時(shí)service層中不能注入分頁類7. golang - 用IDE看docker源碼時(shí)的小問題8. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?9. javascript - mock.js可以存儲(chǔ)數(shù)據(jù)嗎10. docker api 開發(fā)的端口怎么獲取?

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