I have a JSON file which has a user list. I want to get only a specific user from the list, and display it on an index page using Angular. I've searched a lot, but can't get a good answer. The list has to be in a JSON file, not in a JS file.
sampleApp.controller('userInfo', ['$scope', '$http', '$log', '$filter', function($scope, $http, $log,$filter) {
$scope.results = '';
$http.defaults.headers.common['X-Custom-Header'] = 'Angular.js';
$http.get('data/registered-user-list.json').
success(function(data, status, headers, config) {
$scope.results = data;
})
.error(function(data, status, headers, config) {
// log error
});
}]);
The JSON file:
{ "results": [
{
"usernumber": "1",
"userid": "manojsoni",
"userpassword": "password",
"useremail": "manojsoni.online@gmail.com",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
},
{
"usernumber": "2",
"userid": "jasmeet",
"userpassword": "password",
"useremail": "jasmeet@nagarro.com",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
},
{
"usernumber": "3",
"userid": "manoj30dec",
"userpassword": "password",
"useremail": "manoj.kumar@nagarro.com",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
},
{
"usernumber": "4",
"userid": "lavish",
"userpassword": "password",
"useremail": "lavish.sharma@nagarro.com",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
}
]}