I'm new in AngularJS, and i'm trying to paginate an json result, but i have an error. The JSON service returns something like the that:
products.json:
X({
"data":{
"reference":{
"timestamp":"24/02/2014",
"item":{
"id":"123456",
"name":"Reference Product",
"price":"R$ 39,90",
}
},
"arrayData":[
{
"businessId":"123",
"name":"Recommended Product",
"price":"R$ 29,00",
},
{
"businessId":"1234",
"name":"Another Recommended Product",
"price":"R$ 39,00",
},
]
}
});
And my script that process the json is the following:
var todos = angular.module('results', ['ui.bootstrap']);
results.controller('ResultsController', function($scope, $http) {
$scope.makeResults = function() {
$http.get('products.json').success(function(resp){
console.log(resp);
});
};
$scope.makeResults();
});
But when executes the code is printed in the console a plain text, not an object. If I use $http.jsonp instead $http.get, a ReferenceError: X is not defined is apresented. For test only, in jQuery ajax I've tryed the same with the dataType: 'jsonp' and jsonpCallback: "X" options and got resolved the problem.
Can anyone help me?
Thks