Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ionic List Operations

ionic List Operations

A list is a widely used interface element in almost all mobile apps. The two directives ionList and ionItem also support a variety of interaction modes, such as removing an item, dragging to reorder, swipe editing, etc.

Usage





  

    Hello, {{item}}!

  



Advanced usage: thumbnails, delete buttons, reordering, swiping





  



    

    

{{item.title}}

{{item.description}}

分享 编辑

API

property Type Details
delegate-handle

(optional)

| `string` |

This handle defines a list with$ionicListDelegate.

| | show-delete
(optional)
| `boolean` |

Whether the delete button of the list item is currently shown or hidden.

| | show-reorder
(optional)
| `boolean` |

Whether the sort button of the list item is currently shown or hidden.

| | can-swipe
(optional)
| `boolean` |

Whether the list item is allowed to slide to reveal option buttons. Default: true.

|

Example

HTML code:





  

    

    

    Ionic List Directive

   

    

    

  



  

    

    

      

Ionic Delete/Option Buttons

Item {{ item.id }} Edit Share

CSS code



body {

  cursor: url('http://www.runoob.com/try/demo_source/finger.png'), auto;

}

JavaScript Code



angular.module('ionicApp', ['ionic'])



.controller('MyCtrl', function($scope) {

  

  $scope.data = {

    showDelete: false

  };

  

  $scope.edit = function(item) {

    alert('Edit Item: ' + item.id);

  };

  $scope.share = function(item) {

    alert('Share Item: ' + item.id);

  };

  

  $scope.moveItem = function(item, fromIndex, toIndex) {

    $scope.items.splice(fromIndex, 1);

    $scope.items.splice(toIndex, 0, item);

  };

  

  $scope.onItemDelete = function(item) {

    $scope.items.splice($scope.items.indexOf(item), 1);

  };

  

  $scope.items = [

    { id: 0 },

    { id: 1 },

    { id: 2 },

    { id: 3 },

    { id: 4 },

    { id: 5 },

    { id: 6 },

    { id: 7 },

    { id: 8 },

    { id: 9 },

    { id: 10 },

    { id: 11 },

    { id: 12 },

    { id: 13 },

    { id: 14 },

    { id: 15 },

    { id: 16 },

    { id: 17 },

    { id: 18 },

    { id: 19 },

    { id: 20 },

    { id: 21 },

    { id: 22 },

    { id: 23 },

    { id: 24 },

    { id: 25 },

    { id: 26 },

    { id: 27 },

    { id: 28 },

    { id: 29 },

    { id: 30 },

    { id: 31 },

    { id: 32 },

    { id: 33 },

    { id: 34 },

    { id: 35 },

    { id: 36 },

    { id: 37 },

    { id: 38 },

    { id: 39 },

    { id: 40 },

    { id: 41 },

    { id: 42 },

    { id: 43 },

    { id: 44 },

    { id: 45 },

    { id: 46 },

    { id: 47 },

    { id: 48 },

    { id: 49 },

    { id: 50 }

  ];

  

});