I’ve tried to add a ion-delete-button into my ion-list, but when I do that I get this error message in the console:
Error: [$compile:ctreq] Controller ‘ionList’, required by directive ‘ngClick’, can’t be found!
This is my code:
<ion-view title="Alarm">
<ion-nav-buttons side="left">
<button class="button button-clear" ng-class="{'text-bold': showDelete}" ng-if="alarms.length" ng-click="shouldShowDelete()">
{{showDelete ? 'Done' : 'Edit'}}
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<button class="button-icon icon ion-ios7-plus-empty"></button>
</ion-nav-buttons>
<ion-content class="has-header">
<ion-list
show-delete="showDelete"
can-swipe="false">
<ion-item
class="item-collection item-alarm"
ng-class="{disabled: !alarm.active, 'item-icon-right': showDelete}"
collection-repeat="alarm in alarms"
collection-item-height="100">
<ion-delete-button class="ion-ios7-minus-outline" ng-click="delete(item)"></ion-delete-button>
<h2>{{alarm.expiration | time}}</h2>
<p>
<span class="text-bold">{{alarm.title}}</span>
<span ng-if="alarm.repeat">, Weekly{{alarm.repeat}}</span>
</p>
<label class="toggle toggle-balanced" ng-hide="showDelete">
<input type="checkbox" ng-model="alarm.active" ng-change="update(alarm)">
<div class="track">
<div class="handle"></div>
</div>
</label>
<ion-option-button class="button-assertive">
Delete
</ion-option-button>
<i class="icon ion-ios7-arrow-right" ng-show="showDelete"></i>
</ion-item>
</ion-list>
</ion-content>
Here is my controller:
.controller('AlarmCtrl', function($scope, $Alarm) {
// Handle updating of alarm
$scope.update = function(alarm) {
console.log(alarm);
var updatedAlarm = new $Alarm(alarm);
updatedAlarm.$save(function() {
});
};
// Handle deletion of item
$scope.delete = function(item) {
console.log('Deleting');
// $scope.alarms.splice(item, 1);
// Delete in backend
};
// Handle click on edit
$scope.shouldShowDelete = function() {
$scope.showDelete = !$scope.showDelete;
};
// Get alarms
$Alarm.get(function(response) {
$scope.alarms = response.data;
})
})
I’m using Ionic nightly version v1.0.0-beta.5b-nightly-2129.