12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- (function () {
- 'use strict';
- app.controller('BooksList', function($scope) {
- console.log("OK");
- $scope.sortField = 'index';
- $scope.sortBy = function(field) {
- console.log(field);
- $scope.sortField = ($scope.sortField === field) ? '-' + field : field;
- }
- $scope.deleteBook = (bookId) => {
- console.log(bookId);
- console.log($scope.books);
- if ($scope.books.find(x => x.id === bookId)) {
- $scope.books.splice(bookId, 1);
- }
- else if ($scope.books.lenght === 0) return
- else return
-
- }
- $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
- }
- ];
- });
- })();
|