angularjs 二维数组的遍历

我从后台拿到二维数组,想问问怎么通过循环拿到里面的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>


小轩1986
浏览 5525回答 3
3回答

wwpbjing

<!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

通过quest.answer.answered来获取不过你这个json可以拉平的{id:1,number:1,user_id:1,answered:3} 这样不是更直接?

幽凝

quest.answer.answered;但是这是什么奇怪的json
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

AngularJS