I want to change my parent component data state from child component

Parent Component>>>>>>>
I want to change that data “editProfileForm” from “True” to “False” from my child component after api response.

data() {
    return {
           editProfileForm: true,
<div class="card mb-3" v-if="editProfileForm">
    <EditProfile :user="user" @edit-profile="editProfileForm"></EditProfile>

Child Component>>>>>>>>>>>>>

Calling some api and after status 200 I want to fire any function that can help me to change the state of my parent component div.

if (res.status === 200) {
       this.$emit(editProfile, false);

I tried my best but this is not working. Any help would be appreciated

1 Like

The first property of $emit is the name of the emit, the second is the value.

Should be: this.$emit('editProfile')

Actually I had to use ‘edit-profile’ not “editProfile” and now its working >>>>


Interesting, the docs say the case should be auto transformed, so I would’ve expected the camelCase to work. Regardless, glad it’s working for you now.

1 Like