【问题标题】:How to add Object to array in javascript [duplicate]如何在javascript中将对象添加到数组[重复]
【发布时间】:2014-08-29 13:03:48
【问题描述】:

我有这样的代码:

$scope.role.object_access_right = {contact:1,group:1,image:1,text:1,email_template:1,email:1,channel:1,campaign:1,invoice:1,user:1,account:1,tenant:1,}

我这里有空数组,

$scope.access = [];

我怎样才能按下键来清空数组以获得结果?

 $scope.access = [contact,group,text ...]

【问题讨论】:

    标签: javascript angularjs


    【解决方案1】:
    $scope.access = Object.keys($scope.role.object_access_right);
    

    这应该可以解决问题。

    【讨论】:

    • 谢谢和更多问题,我想获得价值并使用:$scope.access = Object.values($scope.role.object_access_right);但它不适合我?
    猜你喜欢
    • 2014-06-04
    • 2013-01-03
    • 2019-03-12
    • 2022-01-05
    • 1970-01-01
    • 2019-07-16
    • 1970-01-01
    • 2014-03-17
    相关资源
    最近更新 更多