<!--customers view-->
<div class="container">
<div class="row">
<div class="col-md-12">
<table class="table table-responsive table-striped">
<tr>
<th ng-click="doSort('name')">Name</th>
<th ng-click="doSort('city')">City</th>
<th ng-click="doSort('order')">OrderTotal</th>
<th ng-click="doSort('joined')">Join</th>
<th>Orders</th>
<th>Delete</th>
</tr>
<tr ng-repeat="cust in customers |filter:customerFilter | orderBy:sortBy:reverse" class="repeat-animation">
<td>{{ cust.name | uppercase }}</td>
<td>{{ cust.city }}</td>
<td>{{ cust.orderTotal | currency: 'AED ' }}</td>
<td>{{ cust.joined | date}}</td>
<td><a href="#/orders/{{cust.id}}">View Orders</a></td>
<td class="center"><span class="glyphicon glyphicon-remove delete" ng-click="remove(cust.id)"></span></td>
</tr>
</table>
</div>
</div>
</div>
/*------------Customer Controller-------------------*/
myApp.controller('CustomersController', ['$scope', 'customersFactory', 'appSettings', function($scope, customersFactory, appSettings) {
var customers = [];
$scope.sortBy = 'name';
$scope.reverse = false;
$scope.appSettings = appSettings;
function init() {
$scope.customers = customersFactory.getCustomers();
}
init();
$scope.doSort = function(propName) {
$scope.sortBy = propName;
$scope.reverse = !$scope.reverse;
}
$scope.remove = function(customer) {
customersFactory.remove(customer);
};
}]);
/* factory remove method*/
factory.remove = function(item) {
factory.customers = _.reject(factory.customers, function(element) {
return element.id === item.id;
});
};
return factory;
I am making table which display the customers and their order and I want to delete the particular orders with the help of underscore reject method, but it is not deleting. My angular version is 1.5. Can anyone suggest the solution?