Reputation: 1
enter code here
How to access objects in Javascript
This is the Object trying to Access
Its returning 'UNDEFINED' why? It may be silly. please help me im new.
CODE :
app.controller("myCtrl", function($scope,Restangular) {
Restangular.setBaseUrl('http://localhost:8080/StrutsREST/api');
var arr=Restangular.all('interfaces').doGET();
var obj=arr.$object;
console.log(obj.A1);
});
Upvotes: -4
Views: 88
Reputation: 17
As you are doing API call which is async you need to handle it as Promise by using .then statement
Restangular.all('interfaces').getList().then(function(data) {
console.log(data.A1);
})
Upvotes: 0