假设数据是这样的。。objList = [{name:"jack",age:23},{name:"lucy",24}]<select class="form-control" (change)="selected($event)"><option *ngFor="let obj of objList" value="{{obj.Value}}">{{obj.Name}}</option> </select>selected($event){ }选择lucy的option时,selected方法怎么拿到当前option的对象集合?即:{name:"lucy",24}
2 回答
阿晨1998
TA贡献2037条经验 获得超6个赞
let selectedIndex = $event.target.selectedIndex;
let selectedItem = selectedIndex > -1 ? this.objList[selectedIndex] : null;
添加回答
举报
0/150
提交
取消