FInding the inner value of a Vuetify chip

I have a Vue application that utilizes Vuetify chips to display information. I'm trying to log the value inside a specific chip when it is clicked, but I keep getting an undefined error when trying to access the array where the information comes from. Can someone please review my code and help me identify the issue?

HTML:

 <v-chip-group
                v-model="selection"
                active-class="deep-purple--text text--accent-4"
                mandatory
            >
              <v-chip
                  v-for="(time, i) in dateTimeArray"
                  :key="time"
                  :value="time.startTime+' | '+time.endTime"
                  @click="pushSelected()"
              >
                {{ time.startTime +" : "+ time.endTime }}
              </v-chip>
            </v-chip-group>

Script:

export default {
  name: "MeetingAdminComponent",
  data : ()=>({
    singleSelect: false,
    selection: "",
    dateTimeArray:[], 
    availableTimes: [
    ],



  }),

  created() {
    this.getAvailableMeetingTimes()
  },

  methods:{

    getAvailableMeetingTimes() {
      var pageURL = window.location.href;
      var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
      axios.get("http://localhost:8080/api/voterAvailableTime/findBy", {

        params: {
          meetingName: lastURLSegment,
        }

      })
          .then(response => (this.availableTimes = response.data)
          )
    },

 getTimesFilteredByDate() {
      var pageURL = window.location.href;
      var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
      var selectedDate = this.selectedDate
      axios.get("http://localhost:8080/api/voterAvailableTime/find", {

        params: {
          meetingName: lastURLSegment,
          date: selectedDate
        }
      })
          .then(response => (this.dateTimeArray = response.data))
    },

    pushSelected(){

      console.log(this.availableTimes.startTime+ " " + this.availableTimes.endTime)
    }
  }
};
</script>

Answer №1

Make sure to pass the current item as a parameter to this method :

          <v-chip
              v-for="(time, i) in dateTimeArray"
              :key="time"
              :value="time.startTime+' | '+time.endTime"
              @click="pushSelected(item)"

This should be included in your methods:

  pushSelected(item){

      console.log(item.startTime+ " " + item.endTime)
    }

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

Determining the state update value in useEffect using dispatch and payload in Redux

Apologies for the confusion in the title. I am currently working with React and Redux-toolkit. I encountered an issue where when referencing the updated value in the useState set function, I ended up getting the value before the update. I understand that ...

Loading tabs dynamically in Angular 2 based on header click event

I successfully created a custom tab component using Angular 2, and it is functioning well with the following usage: <us-tab-verticle> <vtab-content [tabTitle]="'Basic Information'"><basic-info> </basic-info></vtab- ...

Enhancing Performance with Web Workers in Angular CLI

Lately, I've been tackling a challenging issue with my Angular app - heavy computation on the client side leading to UI blockage. My solution? Utilizing Web Workers in my Angular CLI project to separate UI tasks into one thread and heavy processing in ...

add information to a JavaScript "JSON array"

When working in JS (specifically node/js but applicable to general JS), one common issue arises. Upon receiving JSON data from the server, there is often a need to modify it before presenting it on the view. How should this be approached? Creating additi ...

Typescript's Approach to Currying

In TypeScript, I am attempting to define types for a currying function. The implementation in JavaScript is shown below: function curry1(fn) { return (x) => (fn.length === 1 ? fn(x) : curry1(fn.bind(undefined, x))); } This function works effectively ...

Is there a way to transfer HTML code from a textarea to CKEDITOR for setData?

My goal is to retrieve data from a textarea element and use it as setData for CKEDITOR. However, instead of receiving the HTML code, I am only getting the code as a string, which is not rendering properly as HTML. Here's the code snippet: CKEDITOR.re ...

Is it possible to use null and Infinity interchangeably in JavaScript?

I've declared a default options object with a max set to Infinity: let RANGE_DEFAULT_OPTIONS: any = { min: 0, max: Infinity }; console.log(RANGE_DEFAULT_OPTIONS); // {min: 0, max: null} Surprisingly, when the RANGE_DEFAULT_OPTIONS object is logged, i ...

Attempting to retrieve information from my MongoDB database and populate it into a <table> structure on a web page

My objective is to extract data from a MongoDB database and display it in an HTML table. Specifically, I am trying to retrieve information from the hangman database's players collection, which contains fields for name and score. Can anyone help me ide ...

Include an additional section in the stunning Radar Chart

I am trying to use the amCharts 4 library to create a Radar graph similar to this example: In the example, there are two categories being compared with bullets surrounding each one, right? The code I currently have is as follows: am4core.ready(funct ...

Separate the express node js into a pair

I'm attempting to divide a code into two parts using express. Here is how I approached it: app.js var express = require('express'); var app = express(); var stud = require('./grades'); var port = process.env.PORT || 3000; stud. ...

Exploring the possibilities of utilizing classes in testing scenarios with Vue, Cypress, and Cucumber

I am currently working on setting up e2e tests using Cypress and Cucumber for my project. The application is built with Vue CLI 4.1.1, and I have added the package cypress-cucumber-preprocessor (V1.19.0) via NPM. Update: After extensive research and tes ...

Guide to successfully setting up a Json server and ReactJS to run simultaneously on the same port

Currently, I am facing an issue while attempting to run my React application with a JSON server as the backend API. The problem arises when trying to run them on different ports due to a CORS error. I am currently seeking advice and looking for a solutio ...

Can a form component be recycled through the use of inheritance?

Greetings to the Stackoverflow Community, As I delve into this question, I realize that examples on this topic are scarce. Before diving into specifics, let me outline my strategy. I currently have three pages with numerous FormGroups that overlap signif ...

Implement conditional props for a React component by linking them to existing props

In my current project, I am working on a component that has a loading state. The component has an isLoading prop which determines whether the component is currently in a loading state or not: interface CustomImageComponentProps { isLoading: boolean ...

Using jQuery to dynamically add a value to a comment string

Is there a way to dynamically include tomorrow's start and end times in the message for the setupOrderingNotAvailable function if today's end time has passed? The current message states that online ordering will be available again tomorrow from 1 ...

conditional rendering in a cascading sheet

Can the v-if directive be used within a style block in this manner? <style lang="scss" v-if="pinkTheme"> .ac-textfield { background: hotpink; } </style> I attempted to implement this, but unfortunately it did not work (the v-if directive ...

How can I identify and remove duplicate elements from an array of objects?

elements= [ { "id": 0, "name": "name1", "age": 12, "city": "cityA" }, { "id": 1, "name": "name2", "age": 7, "city": "cityC" }, { &qu ...

Manipulating the visibility of components by toggling on click events according to the existing state in ReactJS

Disclosure: I am still getting familiar with ReactJS I'm currently working on incorporating a dialog window for selecting a country/language on the initial page of my application. Here's the concept: There's a small flag button in the to ...

Allowing HTML attributes in reusable components with Vue TSX: A guide on informing Typescript

Imagine I have a custom input component: import { defineComponent } from "@vue/runtime-core" export default defineComponent({ inheritAttrs: false, setup(props, { attrs }) { return () => ( <div> ...

Utilizing the smallslider feature through jQuery/JavaScript operations

I've recently embarked on the journey of learning JavaScript/jQuery. I've been attempting to incorporate this cool effect, but unfortunately, I'm facing some difficulties with it: My goal is to understand how to execute this effect using Ja ...