angulartypescriptmulti-selectangular7

How to submit in array, only id. using Angular 7 and ng-multiselect-dropdown


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.


Solution

  • just use .map which will return new array of permission_id

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