Retrieve data from a different state within a Vue component

Within my application, I have set up 2 distinct routes: one for appointments and the other for doctors. Specifically in the doctors route, my goal is to have the parameters from a click event on the Book Now button (seen in image-1) dynamically replace the values within a select option (illustrated in image-2).

Outlined are my defined routes:

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'appointment',
      component: Appointment
    },
    {
      path: '/doctors',
      name: 'doctor',
      component: Doctor
    },
  ],
})

In Image-1: Within the doctors section, relevant data about different doctors is displayed.

https://i.sstatic.net/k14wL.png

Image-1 Code: Triggering the Book Now button will navigate to the appointment route and update the select options based on specified parameters. Below is the code snippet:

<router-link :class="['btn btn-sm btn-success ml-1 p-1']" :to="{ 
    name: 'appointment', 
    params: {   
                book_hospital_id: item.hospitals.id, 
                book_specialist_id: item.specialists.id , 
                book_doctor_id: item.doctors.id  
            } 
}">Book Now</router-link>

In Image-2: The parameters passed will dynamically change the select options as demonstrated below.

https://i.sstatic.net/hDhNa.png

Image-2 Code:

data: function () {
    return {
        optHospital: '',
        optSpeciality: '',
        optDoctor: '',
    }
},

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

Having trouble parsing bytes from a protobuf message in JavaScript

In my current project, I am faced with the task of encoding and decoding bytes within a protobuf message using Javascript. It seems that working with strings is functional, but once I introduce bytes in the message definition, retrieving the data becomes a ...

Tips for utilizing a printer to print HTML content in PHP

I've stored HTML content in a variable as shown below: $message ="<div> <table align='center'> <tr><td><h1>Tipo de Documentos Report</h1></td></tr> <tr><td>< ...

What steps do I need to take to implement AJAX form authentication?

I have set up a login screen that validates username and password credentials through a php script. When a user enters their information and submits the form, the authenticate.php file executes an LDAP bind. If the credentials are correct, the user is redi ...

Handling invalid JSON strings in controller functions with JavaScript and Node.js

Issue with Incorrect JSON Formatting in Node.js Controller Function Upon sending a JSON object via AJAX to a route in Node.js, the req.body data received in the controller function seems to be incorrectly formatted. What could be causing this issue? Java ...

Implementing Jquery tabs into the code causes the vertical auto-scroll to smoothly glide beyond anchor points

I recently implemented a smooth autoscroll feature on my webpage using the CSS-Tricks code found here: http://css-tricks.com/snippets/jquery/smooth-scrolling/ Everything was working perfectly until I added jQuery tabs to display some of the content. Now, ...

Access view name in controller using Ui-Router

Utilizing the ui-router in AngularJS allows for the implementation of multiple views within the same page/state. While each view consists of a template, controller, and more, there appears to be no straightforward method of assigning a "resolve" function ...

Combining Vue's v-model with :value for maximum control

Currently, I am facing an issue where I can only send the input value to the database instead of the selected image value. It is essential for me to have the selected image value sent to the database. This requires using v-model and :value simultaneously ...

I noticed that while my shareService is effectively sending values in Angular 2, I encounter an issue where my other components are displaying default values instead

I'm in the process of developing an application using angular 2. I have a UserService that sends a value to other components indicating whether a user is logged in or not, and it's working correctly in terms of data transmission. The issue I&apos ...

Teaching you the best way to incorporate numeral.js from app.locals into the script section of my jade file

Encountering issues while trying to utilize numeral.js within the script section of my jade file. Here is how I have numeral placed in locals: app.locals.numeral = require('numeral'); However, when I attempt to use numeral on a variable in my ...

Leverage the power of Angular and Node.js to dynamically generate and configure a new subdomain on an

Currently, I am tackling a project that involves generating sub domains dynamically based on the prefixes entered by users on my website. While everything is functioning properly on my localhost using diet.js and express-subdomain, errors are being encount ...

Ways to transfer property values between two instances of a component

Two datepicker components are present, one for "From" date and another for "To" date. If the "To" date is empty, I want to automatically update it with the value from the "From" date. I have considered using 'emit' on the value but I am unsure ...

Selecting DigitalOcean city based on user location in Node.js

Currently, I am implementing Node.js in conjunction with my HTTP server. My goal is to have every user who connects to the server be linked to a real-time game server through WebSockets. Furthermore, I aim for users to automatically connect to the nearest ...

Encountering a "Unable to use import statement outside a module" issue when trying to import react-hook-mousetrap within a Next.js project

Currently experimenting with Next.js but encountering some challenges. Recently attempted to add react-hook-mousetrap and imported it as per usual: import useMousetrap from "react-hook-mousetrap"; However, this resulted in the following error: S ...

"Unveiling the Benefits of Converting Body to JSON String and Object in Angular 7

Why is it necessary to convert event.body into a JSON string and then parse it back into an object? this.excelFileService.upload(this.currentFileUpload).subscribe(event => { if (event.type === HttpEventType.UploadProgress) { this.progress ...

What are the steps to integrate the vue-tweet-embed node package into vuejs2?

I am having trouble figuring out how to implement the vue-tweet-embed plugin in my Vue file. I keep getting an error message that says: Unknown custom element: - have you properly registered the component? If dealing with recursive components, ensure ...

Issue: unable to inject ngAnimate due to uncaught object error

Whenever I attempt to inject 'ngAnimate' into my app, I encounter issues with instantiation. Here is the code snippet in question: var app = angular.module('musicsa', [ 'ngCookies', 'ngResource', 'ngSanit ...

Angular button will be disabled if the form control is empty

Is there a way to deactivate the search button when the text box is empty? I attempted to use the "disabled" attribute on the search button, but it didn't work. Here is my HTML code: <div class="col-md-5 pl-0"> <div class="in ...

What are the steps to start using the Intersection Observer API right away?

Utilizing the Intersection Observer API, I can accurately determine whether an element is within the viewport or not. Is there a way to utilize the Intersection Observer API to detect if an element is in the viewport without relying on a callback function ...

Incorporating a helper JavaScript file to seamlessly integrate Typeform into a project built with Vue

Struggling with incorporating a typeform into my website through the use of both vue and laravel. The problem arises when trying to embed the typeform using a script, as Vue throws an error when attempting to include the script directly within the compone ...

Is there a way to include @odataid in an ajax request in order to invoke a post method that assigns an owner to a group?

Seeking assistance on how to utilize ajax for adding an Owner to an O365 group. Utilizing the following endpoint: https://graph.microsoft.com/v1.0/groups/{id}/owners/$ref This is my current ajax call setup, where I am passing user information through the ...