0

我有以下代码

var myctrl = function($scope) {
    $scope.items = [{value: 1, name:'Nitin'},{value: 2, name:'Vikas'},{value: 3, name:'xxx'}];
    $scope.itemEdit1 = $scope.items;
    $scope.itemEdit2 = $scope.items.name;
};

我只想将名称复制到 itemEdit2

4

1 回答 1

1

利用$scope.itemEdit2 = $scope.items[0].name;

如果您有兴趣复制所有名称,则应该是:

 $scope.itemEdit2 = [];

 $scope.items.forEach(function(v, i) { 
    $scope.itemEdit2.push({name: v.name});  // or just push(v.name);
 });
于 2013-10-10T12:53:31.050 回答