jeudi 23 juillet 2020

Vue: How to bind checked value from array of objects

For the last 10 hours straight i'm struggling with a seemingly simple issue, i hope someone can assist me.

Situation:

data: {
    user: {
      email: 'test@test.com',
      has_items: [ 
      { "id": 19, "userId": 63, "projectId": 1, "project": { "id": 1, "titel": "Project1" } }, 
      { "id": 20, "userId": 63, "projectId": 2, "project": { "id": 2, "titel": "Project2" } } 
      ]
    },
    items: [
      { "label": "Project1", "titel": "Project1", "projectId": 1 },
      { "label": "Project2", "titel": "Project2", "projectId": 2 },
      { "label": "Project3", "titel": "Project3", "projectId": 3 }
    ]
  }

However, i can't seem to bind the has_items projectId to the checkbox checked state. I'm pretty confident it's one of those cases where messing around made things worse, and a simple solution is overlooked.

I've added an example fiddle: http://jsfiddle.net/ebzgr4c3/31/

Hope someone can point out the error i made, and make this work :)

Thanks!




Aucun commentaire:

Enregistrer un commentaire