Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [{
- "qid": "1",
- "contester": "0",
- "answer": "0",
- "question": "What are you most likely to do after getting into an argument?",
- "images": [{
- "qid": "1",
- "imageid": "AB100",
- "imgname": "doghug_q1",
- "imgpath": "Images/Q1/doghug_q1.jpg"
- },
- {
- "qid": "1",
- "imageid": "AB101",
- "imgname": "eq_q1.jpg",
- "imgpath": "Images/Q1/eat_q1.jpg"
- }, {
- "qid": "1",
- "imageid": "AB102",
- "imgname": "headache_q1",
- "imgpath": "Images/Q1/headache_q1.jpg"
- }, {
- "qid": "1",
- "imageid": "AB106",
- "imgname": "scream_q1.jpg",
- "imgpath": "Images/Q1/scream_q1.jpg"
- }, {
- "qid": "1",
- "imageid": "AB107",
- "imgname": "shopping_q1",
- "imgpath": "Images/Q1/shopping_q1.jpg"
- }, {
- "qid": "1",
- "imageid": "AB108",
- "imgname": "walkAlone_q1",
- "imgpath": "Images/Q1/walkAlone_q1.jpg"
- }]
- }, {
- "qid": "2",
- "contester": "0",
- "answer": "0",
- "question": "Which game would you rather play?",
- "images": [{
- "qid": "2",
- "imageid": "AB105",
- "imgname": "charades_q2.jpg",
- "imgpath": "Images/Q2/charades_q2.jpg"
- }, {
- "qid": "2",
- "imageid": "AB109",
- "imgname": "playingCards_q2.jpg",
- "imgpath": "Images/Q2/playingCards_q2.jpg"
- }, {
- "qid": "2",
- "imageid": "AB110",
- "imgname": "chess_q2",
- "imgpath": "Images/Q2/chess_q2.jpg"
- }, {
- "qid": "2",
- "imageid": "AB111",
- "imgname": "twister_q2",
- "imgpath": "Images/Q2/twister_q2.jpg"
- }]
- }]
- var app = angular.module('myApp', []);
- app.controller('ListCtrl', ['$scope', '$http', function($scope, $http) {
- $http.get('results.json').success(function(data) {
- $scope.questions = [];
- angular.forEach(data, function(question) {
- $scope.questions.push(question)
- });
- $scope.images=[];// get data from json
- angular.forEach($scope.questions, function(sorg) {
- angular.forEach(sorg.images, function(image) {
- $scope.images.push(image)
- });
- });
- console.log($scope.images);
- });
- }]);
- <body ng-app="myApp" >
- <div ng-controller="ListCtrl">
- <ul>
- <li ng-repeat="question in questions"> {{question.qid}}. {{question.question}} </li>
- <li ng-repeat="image in images"> {{image.imgpath}} </li>
- </ul>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement