donal
2018-04-01 875958efd3c90e0d3cffa084f01ff045bacf6b77
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
<template>
    <md-field>
      <label>New ToDo</label>
      <md-input :placeholder="placeholderMsg"
                @keyup.enter="newTodoAdded"
                v-model="newTodo"
      ></md-input>
    </md-field>
  </template>
<script>
import EventBus from "@/services/EventBus"
 
export default {
  name: "NewTodo",
  props: {
    placeholderMsg: String
  },
  data () {
    return {
      newTodo: ''
    }
  },
  methods: {
      newTodoAdded (e) {
          this.newTodo = e.target.value
          console.info('INFO - ', this.newTodo)
          EventBus.$emit('NEWTODOADDED', {
              completed: false, 
              title: this.newTodo,
              id: Math.floor(1 + (9999 - 1) * Math.random())
              })
          this.newTodo = ''
      }
  }
};
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
 
</style>