Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
    
Please post a sample of the data from both tags.json and preguntas.json. –  Alex Ford Jul 18 '14 at 17:13
    
Code is good... must be other problem –  itcouldevenbeaboat Jul 18 '14 at 17:14
    
throw a console.log(data) in each one..see if the data is coming in –  Ronnie Jul 18 '14 at 17:18
    
I've added the jsons, I think they are ok. I've noticed that the second, preguntas.json, gives a 304 response, not a 200. –  Ikzer Jul 18 '14 at 17:25
2  
You have a trailing comma after "text": "Is this okay?", which may cause an error when parsing the JSON. (source: stackoverflow.com/questions/201782/…) –  Sean Walsh Jul 18 '14 at 17:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.