1

I submit this form:

let newRole = this.addForm.value
console.log(this.addForm)

The form is like in image: image

and when I put console.log(this.addForm.value) show this like in image

I want to submit only permission_id, like this :

value: (5) [1, 2, 3, 4, 5]

any suggestions are welcome.

2
  • 1
    Can you ask me any idea please?....You meant any suggestions are welcome. Correct? Commented Nov 1, 2018 at 9:05
  • Yes @Jai Thank you! Commented Nov 1, 2018 at 9:09

2 Answers 2

3

just use .map which will return new array of permission_id

let newRole = this.addForm.value.sp_id.map(v => v.permission_id);
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your answer, this is error ERROR TypeError: this.addForm.value.map is not a function
did you get this.addForm.value before it? try to console it and share the result
0

let newRole = this.addForm.value.sp_id.map((v: any) => v.permission_id);

Use this will return ids only in array

2 Comments

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

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.