(function () { 'use strict'; app.controller('BooksList', function($scope) { console.log("OK"); $scope.sortField = 'index'; $scope.sortBy = function(field) { $scope.sortField = ($scope.sortField === field) ? '-' + field : field; } $scope.deleteBook = function(bookId) { function findBookId(element, index, array) { if (element.id === bookId) return true } var index = $scope.books.findIndex(findBookId); $scope.books.splice(index, 1); } $scope.books = [ { id: 0, title: "Harry Potter", author: "J. ROwling", date: "1970-01-01", cost: 100, rate: 1.2 }, { id: 1, title: "Harry COMPUTER", author: "J. ROwling", date: "1970-01-01", cost: 99, rate: 2.4 }, { id: 2, title: "Harry LIGTER", author: "Git. Bash", date: "2026-05-15", cost: 5, rate: 1 }, { id: 3, title: "Berry Potter", author: "M. Bower", date: "1950-01-01", cost: 88, rate: 3 }, { id: 4, title: "Adam Potter", author: "V. NPM", date: "1870-01-01", cost: 24, rate: 3.2 }, { id: 5, title: "The Things We Don't Say", author: "Carey, Ella", date: "2010-15-01", cost: 42, rate: 1.1 }, { id: 6, title: "Невеста Мрачнейшего", author: "Лилия Лисовская", date: "2018-05-21", cost: 55.6, rate: 5 } ]; }); })();