Cristiano Magro
2024-12-26 f8f722e8a2b63220907736782e547c5a06d88988
add to list an item
2 files modified
15 ■■■■ changed files
03 - lists conditional/lists-cond-01-starting-setup/app.js 6 ●●●● patch | view | raw | blame | history
03 - lists conditional/lists-cond-01-starting-setup/index.html 9 ●●●● patch | view | raw | blame | history
03 - lists conditional/lists-cond-01-starting-setup/app.js
@@ -1,6 +1,10 @@
const app = Vue.createApp({
  data() {
    return { goals: [] };
    return {
      goals: [],
      enteredGoal: '',
     };
  },
  methods: {
    addGoal() {
03 - lists conditional/lists-cond-01-starting-setup/index.html
@@ -20,10 +20,15 @@
      <h2>My course goals</h2>
      <input type="text" v-model="enteredGoal"/>
      <button @click="addGoal">Add Goal</button>
      <p v-if="goals.length === 0">No goals have been added yet - please start adding some!</p>
      <p v-if="goals.length === 0">
        No goals have been added yet - please start adding some!
      </p>
      <ul v-else>
        <li>Goal</li>
        <li v-for="(goal, i) in goals">{{i}} - {{goal}}</li>
      </ul>
      <!-- <ul>
        <li v-for="(value, key) in {nome: 'cristiano', cognome: 'magro'}">{{key}}: {{value}}</li>
      </ul> -->
    </section>
  </body>
</html>