我已经创建了一个反应表单,其中/code>的选项为1,23。
<select id="Ratings" class="form-control" #selectedNumber (change)="Rating(selectedNumber.value)">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select>
在TS文件中,我有这样的内容
Rating(value:number){
this.filteredGames = this.Games.filter(g => g.rating == value);
}
我得到数组filteredGames为空。我尝试将/code>筛选游戏。请帮帮忙
简短的回答:你必须以编程的方式来完成:
Rating(value: string){
this.filteredGames = this.Games.filter(g => g.rating === +value);
}