How To Get Array Value Of Key From Rest Call Response In Angular Js?
I am making a rest call in angular js. I am able to get simple key value from response. But when key's value in array form then I am not able to get value in angular js controller.
Solution 1:
This is because you are referencing res
outside the get
method.
Below code will give you the required data.
Rc.all('demo/example/db/').get('quues/').then(function(res)
{
$scope.demo={}
$scope.demo.details={
value1 : res.Ksus.Type.Master.Origin.ID,
}
$scope.array={}
$scope.array.arrValue={
arrVal : res.Asus[0].AsuID,
}
}
Solution 2:
FYI -
I am assuming ,
in your JSON response between _id and Ksus. After a closer look at your JSON response, your Asus
key exists under Type
-
JSON -
{
_id: 123,
Ksus: {
Type: {
Master: {
Origin: {ID: "Demo"}
},
Asus: [{
AsuID: "f4",
Type: "SU"
}]
}
So to traverse the AsuID
you need to do - res.Ksus.Type.Asus[0].AsuID
Post a Comment for "How To Get Array Value Of Key From Rest Call Response In Angular Js?"