thoughts/web/index.js
web/index.jsRaw
1
2
3angular.module('thoughtsApp', [])
4 .controller('ThoughtsController', function() {
5 var thoughtsList = this;
6 thoughtsList.thoughts = [
7 {
8 time: '9h',
9 content:'primer thought',
10 username: 'user1',
11 fav: '',
12 avatar: 'bat'
13 },
14 {
15 time: '10h',
16 content:'quart thought',
17 username: 'user4',
18 fav: '',
19 avatar: 'tiger'
20 },
21 {
22 time: '10h',
23 content:'segon thought, aquí, provant',
24 username: 'user2',
25 fav: '',
26 avatar: 'toucan'
27 },
28 {
29 time: '10h',
30 content:'tercer thought, responent',
31 username: 'user1',
32 fav: '',
33 avatar: 'bat'
34 },
35 {
36 time: '10h',
37 content:'hola com va',
38 username: 'user3',
39 fav: '',
40 avatar: 'macaw'
41 },
42 {
43 time: '10h',
44 content:'quart thought',
45 username: 'user5',
46 fav: '',
47 avatar: 'giraffe'
48 }];
49
50 thoughtsList.addTodo = function() {
51 todoList.todos.push({text:todoList.todoText, done:false});
52 todoList.todoText = '';
53 };
54
55 thoughtsList.remaining = function() {
56 var count = 0;
57 angular.forEach(todoList.todos, function(todo) {
58 count += todo.done ? 0 : 1;
59 });
60 return count;
61 };
62
63 thoughtsList.archive = function() {
64 var oldTodos = todoList.todos;
65 todoList.todos = [];
66 angular.forEach(oldTodos, function(todo) {
67 if (!todo.done) todoList.todos.push(todo);
68 });
69 };
70 });