1

I'm trying to load data from multiple files, and I'm pretty sure I'm doing it wrong. This is my controller.js:

angular.module('QuizQuestions.controllers', [])
  .controller('Preguntas', function($scope,$http) {
    $http.get('data/preguntas.json').success(function(data) {
        $scope.preguntas = data;
    });
    $http.get('data/tags.json').success(function(data) {
        $scope.tags = data;
    });
  });

preguntas.json:

[
 {
  "id": 1,
  "text": "Is this okay?",
 }
]

tags.json:

[
    { text: 'just' },
    { text: 'some' },
    { text: 'cool' },
    { text: 'tags' }
]

When I try to access the preguntas.json it's empty, it only loads the tags.json, but checking the network responses, I can see that it loads firs tags.json, then preguntas.json, but only loads the data from the first one.

Where I'm wrong here?

Ikzer
  • 527
  • 11
  • 29

0 Answers0