2014-07-08 100 views
0

我有這樣的代碼:如何添加對象到數組中的JavaScript

$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 ...] 

回答

6
$scope.access = Object.keys($scope.role.object_access_right); 

這應該做的伎倆。

+0

感謝和更多的問題,我想獲得價值和使用:$ scope.access = Object.values($ scope.role.object_access_right);但它不適合我? –

相關問題