从列表Ionic删除项目

安德鲁·欧文

我正在建立一个离子型待办事项应用程序。我正在使用删除功能,您单击删除按钮,它将删除列表项,但是遇到问题,无法解决。会显示删除按钮,但是当您单击它时,什么也不会发生。

HTML:

 <ion-view view-title="To-Do">
  <ion-content class="padding">



    <!-- http://ionicframework.com/docs/components/#bar-inputs -->
    <div class="bar bar-header item-input-inset">
      <label class="item-input-wrapper">
        <i class="icon  placeholder-icon"></i>
        <input type="text" ng-model="item.name" placeholder="Enter Task Here">
      </label>
      <button class="button ion-ios-plus-outline" ng-click="addItem(item)">

      </button>
    </div>

    <ion-list>
      <ion-item class="item-remove-animate" ng-repeat="item in items" >
        <h3>{{item.name}}</h3>
        <ion-option-button class="button-assertive ion-trash-a" ng-click="remove($index)"></ion-option-button>
      </ion-item>
    </ion-list>


  </ion-content>
</ion-view>

控制器:

 .controller('ShortTermCtrl', function($scope, Task) {

  $scope.data = Task.data;


  $scope.items = [];
  $scope.item = {};

  $scope.addItem = function (item) {
    $scope.items.push(item);
    $scope.item = {name: ""};

  };

  $scope.removeItem = function(index){
    $scope.items.splice(index, 1);
  };


})
亚历克斯马克

您在视图中使用了错误的函数名称。从更改removeremoveItem

<ion-option-button class="button-assertive ion-trash-a" ng-click="removeItem($index)"></ion-option-button>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章