<select class="form-control" #platformFilter >
<option value="">Select</option>
<option value="PC">PC</option>
<option value="PS3">PS3</option>
<option value="PS4">PS4</option>
<option value="XBox">XBox</option>
<option value="XB1">XB1</option>
</select>
<select class="form-control" #gameFilter >
<option value="">Select</option>
<option value="World of WarCraft">World of WarCraft</option>
<option value="Left 4 Dead 2">L4D2</option>
<option value="Diablo 3">Diablo 3</option>
<option value="Destiny">Destiny</option>
</select>
<input type="datetime-local" class="form-control" #timeFilter >
<button class="btn btn-primary" (click)="applyFilter(platformFilter.value, gameFilter.value, timeFilter.value)">Apply filter</button>
applyFilter(platform:string = null, game:string = null, time:string = null) {
console.log("why?");
}
我不确定我的代码会发生什么 错误是
错误类型错误:无法读取未定义的属性“值” Object.eval [as handleEvent](GroupingComponent.html:231)
那发生了什么?
---------------------------------------编辑:抱歉,包含的细节较少,这是我的完整代码
答案 0 :(得分:0)
为什么它是参数平台:string = null, 尝试将其更改为,
applyFilter(platform: string) {
console.log("why?");
}
答案 1 :(得分:0)
似乎有效,
<select #selectedCategory>
<option value="PC">PC</option>
<option value="PS3">PS3</option>
</select>
<button (click)="getValueFromSelect(selectedCategory.value)">click</button>
`
<强> DEMO 强>
答案 2 :(得分:0)
以下三个对象似乎是null,检查你的打字稿代码。
<button class="btn btn-primary" (click)="applyFilter(platformFilter.value, gameFilter.value, timeFilter.value)">Apply filter</button>