2
I am trying to read a Json file via a service I created:
Service:
App.factory('service', function($http) {
var promise;
get: function() {
if (!promise) {
promise = $http.get('../library/data_json.json')
.success(function (response) {
console.log('success');
promise.data = response;
});
}
return promise.data;
}
});
Controller’s statement
App.controller('CauController', function (service, $http, $scope) {
Now in Controller I call the function that will return me the prefix of $http;
service.get().then(function(data) {
$scope.dados = data;
});
error :
Uncaught Syntaxerror: Unexpected token (
Mark your answer as "Accept" to signal that this answer solved your problem. = D
– celsomtrindade