donal
2018-04-01 82de6c49e5fa5b836b01bf18c4ce6a9bcdd54716
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<template>
  <div class="home">
    <img src="../assets/logo.png">
    <NewTodo placeholderMsg="Add a new todo" @NEWTODOADDED="newTodoAdded"/>
    <TodoItem todoItem="Have a beers"/>
    <ListOfTodos todos="this.todos"/>
 
    <button @click=newTodoAdded>add todo</button>
    <button>getTodos</button>  
    <code>{{ allTodos }}</code>
  </div>
 
</template>
 
<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";
import NewTodo from "@/components/NewTodo.vue";
import TodoItem from "@/components/TodoItem.vue";
import ListOfTodos from "@/components/ListOfTodos.vue";
 
import EventBus from "@/services/EventBus";
 
export default {
  name: "Catalog",
  components: {
    NewTodo,
    TodoItem,
    ListOfTodos
  },
    // load todos on start
  created () {
    this.$store.dispatch('loadTodos')
  },
    // be able to get the data
  computed: {
    allTodos () {
      return this.$store.getters.todos
    },
  },
  methods: {
    newTodoAdded(e) {
      console.info("INFO - ", e);
      
    }
  }
};
</script>