I'm tryining to pass the data from function in component to another component. Everything I googled was about passing the data to child-parent components, but not in my case.
So here is how my main component looks like
<template>
<div>
<h2>Contact List</h2>
<router-link to="/">Home</router-link>
<hr />
<InputForms />
<List />
</div>
</template>
I'm passing the data in <InputForms> component, and I want to receive that data inside <List> components
Here's how I'm passing the data in <InputForms> component
onSubmit() {
let numberValidation = this.numbers.map(el => el.value === "");
let addressValidation = this.addresses.map(el => el.value === "");
let emailsValidation = this.emails.map(el => el.value === "");
let len =
numberValidation.length +
addressValidation.length +
emailsValidation.length;
for (let i = 0; i < len; i++) {
if (
numberValidation[i] === true ||
addressValidation[i] === true ||
emailsValidation[i] === true ||
this.title.trim() === ""
) {
return this.$alert("you have an empty space");
break;
}
}
const newContact = {
name: this.title,
number: this.numbers,
address: this.addresses,
email: this.emails
};
this.$emit("newcontact", newContact);
}
How can I get newContact inside of <List> component?