I want to show the user profile values in HTML via an AngularJs controller, but it isn't showing in the html <p> where I bind them.
jsfiddle
AngularJs App:
var app = angular.module('myApp', []);
app.service('UserService', function () {
var userDetails = [{
id : 27,
first_name : 'Addy',
last_name : 'Villiams',
gender : 1,
email : '[email protected]',
creation_date : '2015-09-23 10:53:19.423',
age : 25,
profile_pic : 'avatar.get?uid=27'
}];
this.get = function () {
return userDetails;
}
});
app.controller('UserController', function ($scope, UserService) {
$scope.userinfo = UserService.get();
});
HTML:
<div ng-controller="UserController">
<p>{{userinfo.id}}</p>
<p>{{userinfo.first_name}}</p>
</div>
var userDetails = [{try returning just the straight object.... fiddle