javascript - How to get object properties if it's inside an array? -
i have js object structure this:
object { name: "name"; id: "id"; subgroups_id : array[1] 0: 9 } i want subgroup_id , turn name of subgroup according id of subgroup, i'm using angularjs , i'm doing this:
var users = angular.module('groups', ['app']); users.controller('groupsctrl', ['$scope', 'apiservice', 'rpcservice', function($scope, apiservice){ function getgroupslist() { $scope.groupslist = []; apiservice.getgroups(0) .success(function (data) { $scope.groupslist = data; console.log($scope.groupslist); }) .error(function (data, status, headers) { }); }; getgroupslist(); }]); if can explain me how appreciate it
thank you.
assume group name in groupslist
$scope.groupslist[yourobj.subgroups_id][0]
--
yourobj.subgroups_id // array[1] 0: 9 yourobj.subgroups_id[0] // 9 $scope.groupslist[9] // value @ index 9 assuming group name
Comments
Post a Comment