I make a Get call to an API, inside my controller I want to access the values of that object how can I do it?, if I use data binding I can view the value of the variable within the object.
var app = angular.module("myApp",["ngResource"]);
app.factory("myAppFactory",function($resource){
return{
Test: $resource("https://jsonplaceholder.typicode.com/users/:id", {id:"@id"})
}
});
app.controller("ctrl",function($scope,myAppFactory){
var productDetailServer = myAppFactory.Test.get({ id: 1 }, function () {
});
var aux=productDetailServer;
$scope.variable = productDetailServer;
console.log(productDetailServer);
console.log("the website\n");
console.log(aux.website);
console.log("how do you access variable inside the response?");
/*
How can I do something like this:
var website =productDetailServer.website
website should access the website within the productDetailServer object but
all I get is undefined, how do I assign the website propierty from the object to the variable?
Thanks
*/
});
But how can I access the value of the variables from the controller? Thanks
I made a Plunker to better explain what I meant: