json - 绑定复选框不适用于我的方法 - Angular
问题描述
首先感谢您的帮助
我正在尝试为绑定复选框操作构建一个逻辑,它将获得一个对象数组(已经内置在我的 model.ts
export class Trip {
constructor(
infoTa: string,
noContent: string,
select: false,
id: number,
idTrasferta: string,
idUtente: string,
dataInizio: string,
dataFine: string,
在创建我的 html 之后
<th scope=^row>
<input
class="form-check-input"
type="checkbox"
style=margin-left:120px
[value]="trip.id"
[checked]="trip.select"
(change)="selectTrip($event)">
</th>
还有我在trips.component上的方法:
export class TripsComponent implements OnInit, RouterModule {
checkedtrips: Trip
selectTrip($event) {
const id = $event.target.value;
const isChecked = $event.target.checked;
console.log(id, isChecked);
this.checkedtrips = this.selectTrip.map((d)=> {
if(d.id == id) {
d.select = isChecked;
return d;
}
})
}
我的地图操作员对此抱怨
类型 '($event: any) => void'.ts(2339) 上不存在属性 'map'
问题是:如何使用我的对象数组来执行此操作并将用户选择的数组导出到另一个组件?
干杯
解决方案
推荐阅读
- node.js - 如何在 Node.js(Express) 中创建嵌套评论
- android - 将一个 recyclerview 项目移动到另一个 recyclerview 按钮单击自定义适配器
- mysql - SQL 按不同表的多列排序
- ng-bootstrap - ngb-accordion 在 ngb-panel 中实现 cdkdrag
- function - 谁能解释我这个断言条件?
- r - R bookdown中的交叉引用使图形名称不正确
- apache-spark - Apache Spark:广播连接行为:过滤连接表和临时表
- python - OU 中的空间导致 ldap 搜索失败
- flutter - 颤振:如何分组两个或多个字段?
- android - 将文件从反应本机图像选择器上传到服务器