Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. [{
  2. "qid": "1",
  3. "contester": "0",
  4. "answer": "0",
  5. "question": "What are you most likely to do after getting into an argument?",
  6. "images": [{
  7. "qid": "1",
  8. "imageid": "AB100",
  9. "imgname": "doghug_q1",
  10. "imgpath": "Images/Q1/doghug_q1.jpg"
  11. },
  12. {
  13. "qid": "1",
  14. "imageid": "AB101",
  15. "imgname": "eq_q1.jpg",
  16. "imgpath": "Images/Q1/eat_q1.jpg"
  17. }, {
  18. "qid": "1",
  19. "imageid": "AB102",
  20. "imgname": "headache_q1",
  21. "imgpath": "Images/Q1/headache_q1.jpg"
  22. }, {
  23. "qid": "1",
  24. "imageid": "AB106",
  25. "imgname": "scream_q1.jpg",
  26. "imgpath": "Images/Q1/scream_q1.jpg"
  27. }, {
  28. "qid": "1",
  29. "imageid": "AB107",
  30. "imgname": "shopping_q1",
  31. "imgpath": "Images/Q1/shopping_q1.jpg"
  32. }, {
  33. "qid": "1",
  34. "imageid": "AB108",
  35. "imgname": "walkAlone_q1",
  36. "imgpath": "Images/Q1/walkAlone_q1.jpg"
  37. }]
  38. }, {
  39. "qid": "2",
  40. "contester": "0",
  41. "answer": "0",
  42. "question": "Which game would you rather play?",
  43. "images": [{
  44. "qid": "2",
  45. "imageid": "AB105",
  46. "imgname": "charades_q2.jpg",
  47. "imgpath": "Images/Q2/charades_q2.jpg"
  48. }, {
  49. "qid": "2",
  50. "imageid": "AB109",
  51. "imgname": "playingCards_q2.jpg",
  52. "imgpath": "Images/Q2/playingCards_q2.jpg"
  53. }, {
  54. "qid": "2",
  55. "imageid": "AB110",
  56. "imgname": "chess_q2",
  57. "imgpath": "Images/Q2/chess_q2.jpg"
  58. }, {
  59. "qid": "2",
  60. "imageid": "AB111",
  61. "imgname": "twister_q2",
  62. "imgpath": "Images/Q2/twister_q2.jpg"
  63. }]
  64. }]
  65.  
  66. var app = angular.module('myApp', []);
  67. app.controller('ListCtrl', ['$scope', '$http', function($scope, $http) {
  68. $http.get('results.json').success(function(data) {
  69.  
  70. $scope.questions = [];
  71.  
  72. angular.forEach(data, function(question) {
  73. $scope.questions.push(question)
  74.  
  75. });
  76.  
  77. $scope.images=[];// get data from json
  78. angular.forEach($scope.questions, function(sorg) {
  79. angular.forEach(sorg.images, function(image) {
  80. $scope.images.push(image)
  81.  
  82. });
  83. });
  84.  
  85. console.log($scope.images);
  86. });
  87. }]);
  88.  
  89. <body ng-app="myApp" >
  90. <div ng-controller="ListCtrl">
  91. <ul>
  92.  
  93. <li ng-repeat="question in questions"> {{question.qid}}. {{question.question}} </li>
  94. <li ng-repeat="image in images"> {{image.imgpath}} </li>
  95.  
  96. </ul>
  97. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement