Andrew Irwin Andrew Irwin - 2 years ago 159
Javascript Question

Delete item from list Ionic

I'm building an ionic to do list app.
I'm working on a delete function where you click the delete button and it will delete the list item, but have I'm having problems and can't figure it out.
the delete button shows, but when you click it nothing happens.


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

<!-- -->
<div class="bar bar-header item-input-inset">
<label class="item-input-wrapper">
<i class="icon placeholder-icon"></i>
<input type="text" ng-model="" placeholder="Enter Task Here">
<button class="button ion-ios-plus-outline" ng-click="addItem(item)">


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



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

$ =;

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

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


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


Answer Source

You use the wrong function name in view. Change it from remove to removeItem:

<ion-option-button class="button-assertive ion-trash-a" ng-click="removeItem($index)"></ion-option-button>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download