I'm 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 statement
App.controller('CauController', function (service, $http, $scope) {
Now in the Controller I call the function that will return the promise of $ http;
service.get().then(function(data) {
$scope.dados = data;
});
error:
Uncaught SyntaxError: Unexpected token (