Skip to content

Conversation

@Gopika4112
Copy link
Contributor

No description provided.

<p v-else>List is empty.</p>
<h2>Favorites List</h2>
<ul v-if="favoriteList.length">
<li v-for="(item, index) in favoriteList" :key="index">{{ item }}</li>
Copy link
Owner

@Dexters-Hub Dexters-Hub Apr 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The :key is a shorthand version of the v-bind:key directive. Similar to v-on:click - @click

<ul v-if="favoriteList.length">
<li v-for="(item, index) in favoriteList" :key="index">{{ item }}</li>
</ul>
<form @submit.prevent="addItem">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code uses the concept of modifiers - the same concept as to how to react to an event in more detail.

</ul>
<form @submit.prevent="addItem">
<label for="newItem">Add new item:</label>
<input type="text" id="newItem" v-model="newItem">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v-modal is a new way for two-way binding. It's majorly used for forms - It automatically handles what to look at and what to change. It's a handy directive.

Here

This is same as:

<input v-model="searchText">

as this:

<input
  v-bind:value="searchText"
  v-on:input="searchText = $event.target.value"
>

evaluate() {
console.log('Evaluate')
addItem() {
if (this.newItem.trim() !== '') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally this refers to the current object - so it looks for the newItem - It is the only way to to track the variables inside data in methods. But this will be changed when we look at composition API :D

Copy link
Owner

@Dexters-Hub Dexters-Hub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 🥇 @Gopika4112 - I've added comments for to convey the stuff that is happening underneath

@Dexters-Hub Dexters-Hub changed the base branch from main to dev April 14, 2024 13:52
@Dexters-Hub Dexters-Hub merged commit 4ce85bf into Dexters-Hub:dev Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants