I am struggling with extracting a specific user from a JSON file containing a user list and displaying it on an Angular index page. Despite extensive research, I have been unable to find a satisfactory solution. The user list must remain in a JSON file instead of 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": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b2dfd3dcddd8c1dddcdb9cdddcdedbdcd7f2d5dfd3dbde9cd1dddf">[email protected]</a>",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
},
{
"usernumber": "2",
"userid": "jasmeet",
"userpassword": "password",
"useremail": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="046e657769616170446a65636576766b2a676b69">[email protected]</a>",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
},
{
"usernumber": "3",
"userid": "manoj30dec",
"userpassword": "password",
"useremail": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="066b6768696c286d736b677446686761677474692865696b">[email protected]</a>",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
},
{
"usernumber": "4",
"userid": "lavish",
"userpassword": "password",
"useremail": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f232e39263c27613c272e3d222e0f212e282e3d3d20612c2022">[email protected]</a>",
"timestamp": "1:30pm",
"datestampe": "25/01/2016"
}
]}