Javascript 如何使用angular JS创建新数组?

Javascript 如何使用angular JS创建新数组?,javascript,arrays,angularjs,Javascript,Arrays,Angularjs,若要使用存储在变量中的名称创建对象属性,应使用括号表示法。就你而言: <html ng-app=""> <body ng-controller="controller"> <button class="btn" ng-click="create('new') >Click</button> </body> </html> <script> function controller($scope) {

若要使用存储在变量中的名称创建对象属性,应使用括号表示法。就你而言:

<html ng-app="">
<body ng-controller="controller">
    <button class="btn"  ng-click="create('new') >Click</button>
</body>
</html>

<script>
function controller($scope) {
    $scope.create = function(id) {
        // What will be the code to create a new array 
        // having name contained in variable?
    };
}
<script>
function controller($scope) {
    $scope.create = function(id) {
        $scope[id] = [];
        // do something with new array
    };
}