1

当我单击“添加更多”按钮时,我希望有一个自附加输入框。

我目前拥有的是以下内容,我希望当我点击链接时,每次点击都会附加输入。

<div ng-repeat="item in items" slide-show="showInput">
  <input name="item.id">
</div>
<div>
  <a href ng-click="showInput=true">add more</a>
<div>
4

1 回答 1

3

只需在 items 数组中添加一个新项目。

function SampleCtrl ($scope) {
   $scope.items = [obj1,obj2,obj3];
   $scope.showItem = false;
   $scope.addItem = function () {
       //it's up to you how you want to structure the new_object.
       var new_object;
       $scope.showInput = true;
       $scope.items.push(new_object);
   }
}

在您ng-click调用该addItem函数时。

于 2013-09-16T04:55:53.887 回答