How to mark checked for the values that are recievd from api into checkbox in VUEJS

Viewed 29

I am learning VUEJS recently. I cannot move further as i am stuck in an issue. ISSUE:

i am getting a list from an api call. Here is the section of code for this:

           <b-form-checkbox-group
              v-model="authorize"
              :options="authorize"
              name="authorize"
              stacked
              text-field="name"
              value-field="id"
            >

I am getting this using .get('/authorize') and i have these values:

[{"id":"country:list","name":"country:list"},{"id":"country:create","name":"country:create"},{"id":"user:retrieve","name":"user:retrieve"},{"id":"user:update","name":"country:update"},{"id":"country:destroy","name":"user:destroy"}]

In another form i have added some of these value and in response, i get these values

[{"id":"country:list","name":"country:list"},{"id":"country:create","name":"country:create"},{"id":"user:retrieve","name":"user:retrieve"}]

i get these response using this:

          <b-form-checkbox-group
              v-model="authorize"
              :options="currentTutorial.authorize"
              name="authorize"
              stacked
              text-field="name"
              value-field="id"
            >

But what i want now is that i want to display all the authorize list along with the save items but those saved items should be checked which i am getting from currentTutorial.authorize here

Appreciate your help. thank you

1 Answers
<b-form-checkbox-group
              v-model="authorize.id"
              :options="authorize"
              name="authorize"
              stacked
              text-field="name"
              value-field="id"
            >

can you change v-model variable liked as this

Related