0

I've got a votes array with users. Now I would like to remove a user based on his id.

role: 2
active: 2
about: null
id: 3
email: "[email protected]"
created_at: "2016-11-08 17:14:16"
function: "functie...."
last_name: "Janssen"
mobile: "6"
pivot: Object
updated_at: "2016-11-08 17:30:20"

Method:

option.votes.$remove($root.user.id);

Obviously this is not working. How do I get this to work?

1
  • Are you using vue 2.0? $remove has been deprecated in 2.0. Commented Nov 9, 2016 at 10:52

1 Answer 1

2

Try this:

newArray = myArray.filter(function( obj ) {
    return obj.id !== 'idToDelete';
});
option.votes = newArray
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.