Explorar el Código

Без работы с сервером

Vlad Seleznev hace 6 años
commit
e80fe17ce3

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/node_modules

+ 0 - 0
app/app.config.js


+ 1 - 0
app/app.module.js

@@ -0,0 +1 @@
+var app = angular.module('MyApp', []);

+ 0 - 0
app/app.routes.js


+ 100 - 0
app/controllers/books-list.controller.js

@@ -0,0 +1,100 @@
+(function() {
+	'use strict';
+	app.controller('BooksList', function($scope){
+		$scope.sortFild = 'title';
+		$scope.sortBy = function(field){
+			$scope.sortFild = ($scope.sortFild === field)? '-'+ field : field;
+		};
+		$scope.deleteBook = function(index){
+			console.log(index.id)
+			console.log($scope.books[0])
+			for (var i = 0; i < $scope.books.length; i++) {
+				if (index === $scope.books[i].id) {
+					$scope.books.splice(i,1);
+				}
+			}
+		}
+		$scope.books = [
+			{
+				title: 'Harry Potter',
+				author: 'J. Rowling',
+				date: '1998-01-01',
+				cost: '300$',
+				rate: '50',
+				id: 1
+			},
+			{
+				title: 'Terra Ucrainica',
+				author: 'Д. Вортман',
+				date: '1991-12-11',
+				cost: '100$',
+				rate: '4',
+				id: 2
+			},
+			{
+				title: 'Аеропорт',
+				author: 'А. Гейлі',
+				date: '2000-03-03',
+				cost: '500$',
+				rate: '3',
+				id: 3
+			},
+			{
+				title: 'Бог завжди подорожує інкогніто',
+				author: 'Л. Гунель',
+				date: '2001-10-12',
+				cost: '200$',
+				rate: '4',
+				id: 4
+			},
+			{
+				title: 'Джерело. Клубне видання',
+				author: 'Д. Браун',
+				date: '1999-10-11',
+				cost: '500$',
+				rate: '5',
+				id: 5
+			},
+			{
+				title: 'Вежа блазнів',
+				author: 'А. Сапковський',
+				date: '1993-04-02',
+				cost: '400$',
+				rate: '8',
+				id: 6
+			},
+			{
+				title: 'Ненавижу, потому что люблю',
+				author: 'Н. Соболевская',
+				date: '2011-10-03',
+				cost: '100$',
+				rate: '10',
+				id: 7
+			},
+			{
+				title: 'Крейдяна Людина',
+				author: 'С. Дж. Тюдор',
+				date: '1990-03-08',
+				cost: '10$',
+				rate: '2',
+				id: 8
+			},
+			{
+				title: 'Джерело. Суперобкладинка',
+				author: 'Д. Браун',
+				date: '2000-03-05',
+				cost: '500$',
+				rate: '20',
+				id: 9
+			},
+			{
+				title: 'Великий атлас світу',
+				author: 'ред. О. Король',
+				date: '1997-10-11',
+				cost: '300$',
+				rate: '5',
+				id: 10
+			},
+		]
+	})
+})()

+ 52 - 0
app/controllers/main.controller.js

@@ -0,0 +1,52 @@
+(function() {
+	'use strict';
+
+	app.controller('Main', function($scope){
+		 // $scope.phones = [{
+	  //       name: 'Nokia Lumia 630',
+	  //       year: 2014,
+	  //       price: 200,
+	  //       company: {
+	  //           name: 'Nokia',
+	  //           country: 'Финляндия'
+	  //       }
+	  //   },{
+	  //       name: 'Samsung Galaxy S 4',
+	  //       year: 2014,
+	  //       price: 400,
+	  //       company: {
+	  //           name: 'Samsung',
+	  //           country: 'Республика Корея'
+	  //       }
+	  //   },{
+	  //       name: 'Mi 5',
+	  //       year: 2015,
+	  //       price: 300,
+	  //       company: {
+	  //           name: 'Xiaomi',
+	  //           country: 'Китай'
+	  //       }
+	  //   }]
+	  $scope.lists = [
+	  	{text: 'Покормить кота',},
+	  	{text: 'Покормить кота',},
+	  	{text: 'Покормить кота',},
+	  	{text: 'Покормить кота',}
+	  ];
+	  $scope.style = {
+	  	width: 100,
+	  	height: 100,
+	  	background: 'red'
+	  }
+	  
+	  console.log($scope.lists)
+	    $scope.addItem = function(item){
+	    	$scope.lists.push($scope.item)
+	    	$scope.item = "";
+	    };
+	    $scope.deletItem = function(item){
+	    	$scope.lists.splice(item, 1);
+	    };
+
+	})
+})();

+ 65 - 0
index.html

@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html ng-app='MyApp'>
+<head>
+	<meta charset="utf-8">
+	<title>My To Do Angular</title>
+	<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
+</head>
+<body>
+	<!-- <div ng-controller='Main' class="container">
+		<div class="page-header">
+			<h1>Seleznev Do IT</h1>
+		</div>
+		<div class="content">
+			<input type="numder" ng-model='value'> {{value * 3}}
+			<input type="text" ng-model='item'>
+			<button ng-click='addItem()'>Add</button>
+			<ul>
+				<li ng-repeat='list in lists track by $index'>{text}<button class="btn-danger" ng-click='deletItem($index)'>X</button></li>
+			</ul>
+			<label>width</label>
+			<input type="numder" ng-model='style.width'>
+			<label>height</label>
+			<input type="numder" ng-model='style.height'>
+			<label>background</label>
+			<input type="text" ng-model='style.background'>
+			<div ng-style='{width: style.width + "px", height: style.height + "px", background: style.background}'></div>
+		</div>
+	</div> -->
+	
+	<div ng-controller='BooksList' class="container">
+		<div class="page-header">
+			<h1>Books</h1>
+		</div>
+		<div class="page-boody">
+			<input type="text" ng-model='searchString' placeholder="Filter" class="form-control">
+			<table class="table-bordered table-hover container">
+				<thead>
+					<td ng-click='sortBy("title")'><i class="glyphicon" ng-class='{"glyphicon glyphicon-chevron-up": sortFild === "title", "glyphicon glyphicon-chevron-down": sortFild === "-title"}'></i>Title</td>
+					<td ng-click='sortBy("author")'><i class="glyphicon" ng-class='{"glyphicon glyphicon-chevron-up": sortFild === "author", "glyphicon glyphicon-chevron-down": sortFild === "-author"}'></i>Author</td>
+					<td ng-click='sortBy("date")'><i class="glyphicon" ng-class='{"glyphicon glyphicon-chevron-up": sortFild === "date", "glyphicon glyphicon-chevron-down": sortFild === "-date"}'></i>Date</td>
+					<td ng-click='sortBy("cost")'><i class="glyphicon" ng-class='{"glyphicon glyphicon-chevron-up": sortFild === "cost", "glyphicon glyphicon-chevron-down": sortFild === "-cost"}'></i>Price</td>
+					<td ng-click='sortBy("rate")'><i class="glyphicon" ng-class='{"glyphicon glyphicon-chevron-up": sortFild === "rate", "glyphicon glyphicon-chevron-down": sortFild === "-rate"}'></i>Rate</td>
+					<td></td>
+				</thead>
+				<tbody>
+					<tr ng-repeat='item in books | orderBy:sortFild  | filter: searchString'>
+						<td>{{item.title}}</td>
+						<td>{{item.author | uppercase}}</td>
+						<td>{{item.date | date: 'longDate'}}</td>
+						<td>{{item.cost}}</td>
+						<td>{{item.rate | number : 1}}</td>
+						<td>
+							<button class="btn btn-danger" ng-click='deleteBook(item.id)'></button>
+						</td>
+					</tr>
+				</tbody>
+			</table>
+		</div>
+	</div>
+	<script type="text/javascript" src="./node_modules/angular/angular.js"></script>
+	<script type="text/javascript" src="app/app.module.js"></script>
+	<!-- <script type="text/javascript" src="app/controllers/main.controller.js"></script> -->
+	<script type="text/javascript" src="app/controllers/books-list.controller.js"></script>
+</body>
+</html>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 9607 - 0
package-lock.json


+ 22 - 0
package.json

@@ -0,0 +1,22 @@
+{
+  "name": "2018-06-01",
+  "version": "1.0.0",
+  "description": "",
+  "main": "webpack.config.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "server": "webpack-dev-server --color --watch-content-base --open"
+  },
+  "author": "",
+  "license": "ISC",
+  "devDependencies": {
+    "html-webpack-plugin": "^3.2.0",
+    "webpack": "^3.12.0",
+    "webpack-cli": "^2.1.4",
+    "webpack-dev-server": "^2.11.2"
+  },
+  "dependencies": {
+    "angular": "^1.6.6",
+    "bootstrap": "^3.3.7"
+  }
+}

+ 16 - 0
webpack.config.js

@@ -0,0 +1,16 @@
+const path = require('path');
+const glob = require('glob');
+
+const config = {
+	context: path.resolve(__dirname, './'),
+	entry: {
+		app: './app/app.module.js',
+	},
+	devServer: {
+		port: 9000,
+		stats: 'errors-only'
+	}
+};
+
+module.exports = config;
+