If have a straight ahead controller:
controller: function($scope, $http){
$http.get(templateSource+'/object.customer')
.then(function(result){
$scope = result.data;
});
}
My object.customer file looks like:
[{"customer":{"name":"Bert","email":"[email protected]"}}]
Now I wanted to access the email, so I did (in HTML)
{{customer.email}}
But this is incorrect, so my question is, how to access email?
UPDATE
Setting:
controller: function($scope, $http){
$http.get(templateSource+'/object.customer')
.then(function(result){
$scope.customer = {};
angular.extend($scope.customer,result.data[0]);
console.log($scope.customer.email);
});
}
Gives me in the console.log unidentified. However, if I set it to console.log($scope.customer); I get:
Object 0:
Object customer:
Object email: "[email protected]"
name: "Bert"
The console.log(result.data) is
[Object]
0: Object
customer: Object
email: "[email protected]"
name: "Bert"
$scope.customers = result.data;Also, you are bringing back an array. If you intend to use the first item (after checking th elength), do$scope.customer = result.data[0];console.log(result.data)output?