Skip to content

Commit 1cc4c8b

Browse files
committed
Added project files
1 parent 559685a commit 1cc4c8b

File tree

15 files changed

+28830
-0
lines changed

15 files changed

+28830
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "mean-todo",
3+
"version": "1.0.0",
4+
"description": "This is the course repo for [Building a MEAN Application](https://teamtreehouse.com/library/building-a-mean-application) on [Treehouse](https://teamtreehouse.com/) by Huston Hedinger and Ken Howard.",
5+
"main": "src/app.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/treehouse/mean-todo.git"
12+
},
13+
"author": "",
14+
"license": "ISC",
15+
"bugs": {
16+
"url": "https://github.com/treehouse/mean-todo/issues"
17+
},
18+
"homepage": "https://github.com/treehouse/mean-todo#readme",
19+
"dependencies": {
20+
"express": "4.13.4"
21+
}
22+
}

public/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title></title>
5+
<link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
6+
<link rel="stylesheet" href="/styles/main.css" type="text/css">
7+
</head>
8+
<body ng-app="todoListApp">
9+
10+
<h1>My TODOs!</h1>
11+
12+
<div class="list" ng-controller="mainCtrl">
13+
<div class="add">
14+
<a href="#" ng-click="addTodo()">
15+
+ Add a New Task</a>
16+
</div>
17+
<todo></todo>
18+
</div>
19+
20+
21+
<script src="/vendor/angular.js"></script>
22+
<script src="/scripts/app.js"></script>
23+
<script src="/scripts/controllers/main.js"></script>
24+
<script src="/scripts/controllers/todo.js"></script>
25+
<script src="/scripts/services/data.js"></script>
26+
<script src="/scripts/directives/todo.js"></script>
27+
</body>
28+
</html>

public/mock/todos.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{"name": "clean the house"},
3+
{"name": "water the dog"},
4+
{"name": "feed the lawn"},
5+
{"name": "pay dem bills"},
6+
{"name": "run"},
7+
{"name": "swim"}
8+
]
9+

public/scripts/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'use strict';
2+
3+
angular.module('todoListApp', []);

public/scripts/controllers/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
angular.module('todoListApp')
4+
.controller('mainCtrl', function($scope, dataService){
5+
6+
dataService.getTodos(function(response){
7+
var todos = response.data;
8+
$scope.todos = todos;
9+
});
10+
11+
$scope.addTodo = function() {
12+
$scope.todos.unshift({name: "This is a new todo.",
13+
completed: false});
14+
};
15+
16+
})

public/scripts/controllers/todo.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
angular.module('todoListApp')
4+
.controller('todoCtrl', function($scope, dataService) {
5+
$scope.deleteTodo = function(todo, index) {
6+
$scope.todos.splice(index, 1);
7+
dataService.deleteTodo(todo);
8+
};
9+
10+
$scope.saveTodos = function() {
11+
var filteredTodos = $scope.todos.filter(function(todo){
12+
if(todo.edited) {
13+
return todo
14+
};
15+
})
16+
dataService.saveTodos(filteredTodos);
17+
};
18+
});

public/scripts/directives/todo.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
angular.module('todoListApp')
4+
.directive('todo', function(){
5+
return {
6+
templateUrl: 'templates/todo.html',
7+
replace: true,
8+
controller: 'todoCtrl'
9+
}
10+
});

public/scripts/services/data.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
angular.module('todoListApp')
4+
.service('dataService', function($http) {
5+
this.getTodos = function(cb) {
6+
$http.get('/mock/todos.json').then(cb);
7+
};
8+
9+
this.deleteTodo = function(todo) {
10+
console.log("I deleted the " + todo.name + " todo!");
11+
};
12+
13+
this.saveTodos = function(todos) {
14+
console.log("I saved " + todos.length + " todos!");
15+
};
16+
17+
});

public/styles/checkbox-empty.svg

Lines changed: 9 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)