我从后台拿到二维数组,想问问怎么通过循环拿到里面的answered数组大约是这样的js:questions=[{id:1, number:1, answer{user_id:1, answered:3}},{id:2, number:2, answer{user_id:1, answered:4}},{id:3, number:3, answer{user_id:1, answered:5}},]html<tr ng-repeat="quest in questions"><td ng-bind="quest.answered"></td><td></td></tr>
3 回答
已采纳
wwpbjing
TA贡献20条经验 获得超5个赞
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>AngularJS</title> <script type="text/javascript" src="angular.min.js"></script> </head> <body ng-app="qApp"> <table ng-controller="QuestionController"> <tr ng-repeat="quest in questions"> <td>{{quest.answer.answered}}</td> <td ng-bind="quest.answer.answered"></td> </tr> </table> <script type="text/javascript"> var qAppModule = angular.module("qApp",[]); qAppModule.controller('QuestionController', function ($scope) { $scope.questions=[ {id:1, number:1, answer:{user_id:1, answered:3}}, {id:2, number:2, answer:{user_id:1, answered:4}}, {id:3, number:3, answer:{user_id:1, answered:5}}, ]; } ); </script> </body> </html>
nickylau82
TA贡献128条经验 获得超67个赞
通过quest.answer.answered来获取
不过你这个json可以拉平的
{id:1,number:1,user_id:1,answered:3} 这样不是更直接?
- 3 回答
- 0 关注
- 5524 浏览
添加回答
举报
0/150
提交
取消