Leverage Vue's ability to assign data from a parent component to

I am struggling to bind the data (inputData) from the parent component to my child component. I have checked my code multiple times but cannot find where the mistake is.

MainApp.js

let vm = new Vue({
    el: "#app",
    components: {
        'modal-panel': modal,
        'rich-select': richSelect,
        'file-upload': uploader,
    },
    data(){ return {
        isModalActive: false,
        inputData: null
    }} ,
    methods: {
        toggleModal(){
            this.isModalActive = !this.isModalActive
        },
        modalData(){
            this.inputData = 'Example Data'
        }
    }
});

ModalComponent.vue

<template>
  <input type="text" :value="inputData" >
</template>


export default {
    name: 'modal',
    props: ['inputData'],
    mounted(){
        console.log('modal Mounted')
    }
};

In my blade file, I am including the modal component like this:

<div class="container"  id="app">    
  <modal-panel v-if="isModalActive" @close="toggleModal" :inputData="inputData"></modal-panel>
</div>

Although all methods are working fine, the ModalComponent.vue input field is still not getting properly bound.

Answer №1

Remember, when using the prop it must be in kebab-case format like this :

<modal-panel v-if="isModalActive" @close="toggleModal" :input-data="inputData"></modal-panel>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can user input be converted into a JavaScript variable?

Looking for help with my webpage - I want users to input their name and age. After hitting submit, I'd like the first input to be stored in a variable called 'name', and the second input in a variable called 'age'. Is this doable? ...

Creating multi-dimensional arrays using array lists with Axios and Vue.js

My knowledge of axios and JavaScript is limited, and I find myself struggling with creating a multi-dimensional array. 1. This is how I want my data to be structured : https://i.stack.imgur.com/kboNU.png userList: [ { ...

Troubleshooting Vue.js unit test issues caused by log messages from internal components

I am working with a component structured like this: <template> <p>{{ message }}</p> <internal-comp></internal-comp> </template> <script> import InternalComp from './components/InternalComp.vue'; ...

Images are no longer accessible from the public directory once a certain route is reached

My app has default layouts (footer and header) set for all pages: page.default.layout = name.startsWith("Dashboard/") ? undefined : MainLayout; The footer uses an image from the public directory, public/images/ <img src="images/payment.png" class="img- ...

Experience the power of CanJS Observable data objects with the added feature of

When working with canJS Observable, I encountered an issue where I cannot use dots in object keys because canJS interprets them as nesting. For example, if I try to create a new observable like this: var obs = new can.Observe( { "div.test-class": { "color ...

Exploring the Depths of React by Cycling Through Arrays in Tabular Format

One issue I'm facing is that I have an array named paymentMethods which I'd like to iterate through in tabs. However, I seem to be struggling with the iteration part. To take a closer look at my code, please visit my codesandbox HERE <div& ...

When implementing helmetJS into my project, I noticed that Font Awesome was displaying white squares

Initially, I created an application that utilized this code in the HTML and incorporated classes with Font Awesome icons, which functioned effectively. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css&q ...

Having trouble getting your AngularJS code to work?

Recently, I decided to experiment with AngularJS and started working on a new project. Below is the HTML code I wrote: <div ng-app ng-controller="nameController"> <input type="text" value="Jack" ng-model="fname" /> <input type="tex ...

Transformer Class: An object containing properties that are instances of another class

class ClassA { x: number; y: number; sum(): number { return this.x + this.y; } } class ClassB { @Type(() => ClassA) z: {[key: string]: ClassA}; } const b = transformObject(ClassB, obj); const z = b.z[key]; const s = z.s ...

Vue.js 2 maintains a collection of items

I have a method that renders a list, but when I click on one of the list items, the list disappears. I also added the showDetail() method. How can I prevent the list from disappearing? data: function () { return { show ...

Can JQuery be used to identify the CSS styles applied to selected elements?

Highlight the text by selecting it and clicking a button. If the text is already highlighted, clicking the button should make the selected text return to normal. Can this be achieved using jQuery and a single button? Is it possible to identify the CSS st ...

Implementing a Basic jQuery Animation: How to Easily Display or Conceal DIV Elements Using fadeIn and fadeOut

SCENARIO: Include 2 links, MY INFO and LOG IN, within a list of ul, li elements. Hovering over one link should display a box with a form inside using the fadeIn animation. The other link should show a button in a box with a fadeIn animation when hovered o ...

Compiling with Gulp Browserify may have longer processing times after each save or change

I have been working on improving the speed of my Gulp workflow by using Browserify. The approach I am taking is heavily influenced by this informative blog post: Initially, everything seems to be functioning well with changes reflecting quickly (around 50 ...

Tips for displaying two dynamic variables that are interdependent

For instance: Controller: AllBooks[{ book1:{ hardcover{price:25.99},e-book{price:1.99} } }, book2:{ hardcover{price:60.00},e-book{price:2.99} }]; $scope.bookchoice = function(selectedBook) { $rootScope.choice = selectedBook;} $scope.booktype = functio ...

Clicking on a button in the Shield UI Grid Toolbar will apply filters to

Currently, I am working with a grid that utilizes a template for the toolbar. In this grid, there is a column labeled "Status." My goal is to filter the rows so that only those where the Status equals Request to Reschedule, Cancelled, Office Call Required, ...

Is it possible to use setState after a setTimeout to unmount a component?

Can anyone help me find the issue with my code? I am attempting to clear an error message after a specific duration, but it's not working as expected. I'm puzzled about what might be causing this problem. export default class MyError extends Com ...

Obtaining images from JSON data and displaying them in a modal using AngularJS

Utilizing AngularJS to retrieve a JSON file: { "albumId": 1, "id": 1, "title": "accusamus beatae ad facilis cum similique qui sunt", "url": "http://placehold.it/600/92c952", "thumbnailUrl": "http://placehold.it/150/92c952" }, and showcasing it with ...

Accessing Data from the Wikipedia API

After receiving a JSON response with the following structure: { "batchcomplete": "", "query": { "pages": { "97646": { "pageid": 97646, "ns": 0, "title": "Die Hard", "extract": "Die Hard is a 1988 ...

Is there a way to load a JSON configuration file and have the Vue application wait for it to be loaded?

My usual setup involves: a webpack-packed Vue app a dedicated configuration file to set up the app The configuration file is excluded from the deployment package generated by webpack, as it contains server-specific details (such as database credentials) ...

Calculating minutes per hour during a specific date range using JavaScript

What is the method to create an array representing minute counts per hour within a specified date range? If we have the following dates: const initial = new Date('2019-04-04 12:14'); const final = new Date('2019-04-04 16:21'); How ca ...