I have this arrays.
filteredData = [ {roles: 1,2,3,4},
{roles: 4,3,2,1} ]
role = [ {role_id: 1, role_name: User},
{role_id: 2, role_name: Coach},
{role_id: 3, role_name: Admin},
{role_id: 4, role_name: Participator} ]
How can I change the roles
in filteredData
into role_name
based on role_id
?
CodePudding user response:
Take a look at following snippet please :
new Vue({
el: '#demo',
data() {
return {
email: null,
filteredData: [{ind_id: 1, first_name: "aaa", last_name: "bbb", email: "[email protected]", roles: [1,2]}, {ind_id: 2, first_name: "ccc", last_name: "ddd", email: "[email protected]", roles: [2, 3, 4]}],
roles: [{role_id: 1, role_name: "Participant"}, {role_id: 2, role_name: "Coach"}, {role_id: 3, role_name: "Admin"}, {role_id: 4, role_name: "User"}]
}
},
methods: {
//