I have a json file that has an array in it:
{
"people": [
{"number":"1", "name":"Gary", "surname":"Peterson", "age":"25"},
{"number":"2", "name":"Andy", "surname":"Smith", "age":"26"},
{"number":"3", "name":"Michael", "surname":"Johnson", "age":"28"}
]
}
I want to return only the first object (person record) to my application. When I call the http service in AngularJS and pass the parameter, like this:
angular.module('mod', [])
.controller('ctrl', function($scope, $http){
$scope.serviceMethod = function(){
$http.get("url to database.json", {params: {number: 1}})
.then(function Succes(response) {$scope.person = response.data.people;});};
});
it returns all three objects. I see no errors in the console in the console (status 200) and the parameter IS passed (it builds this url: http://urltowebsite.com/database.json?number=1).
What am I missing here?
numberproperty??$scope.person = response.data.people[0]