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?
tags.json
andpreguntas.json
. – Alex Ford Jul 18 '14 at 17:13"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