【问题标题】:How to submit in array, only id. using Angular 7 and ng-multiselect-dropdown如何在数组中提交,只有 id。使用 Angular 7 和 ng-multiselect-dropdown
【发布时间】:2018-11-01 09:01:48
【问题描述】:

我提交此表格:

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

表格如图所示:

当我输入console.log(this.addForm.value) 时,在 中显示此内容

我只想提交permission_id,像这样:

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

欢迎提出任何建议。

【问题讨论】:

  • 你能问我任何想法吗?....你的意思是欢迎任何建议。对吗?
  • 是的@Jai 谢谢!

标签: angular typescript multi-select angular7


【解决方案1】:

只需使用.map,它将返回permission_id 的新数组

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

【讨论】:

  • 感谢您的回答,这是错误ERROR TypeError: this.addForm.value.map is not a function
  • 你之前收到this.addForm.value了吗?尝试安慰它并分享结果
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-03-31
  • 2019-06-02
  • 2020-12-15
  • 1970-01-01
  • 2020-06-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多