为了支持Selenium的自动化测试,我需要为Angular Material md-select中的每个md-option指定id。我想用前缀启动带零的id。示例:modelYear-0,modelYear-1
这不起作用,id仍为id =“md-option-275”
<md-select id="modelYearDropdown">
<md-option *ngFor="let modelYear of modelYearList" [value]="modelYear.value" [id] = "modelYear.value" >
{{ modelYear.viewValue }}
</md-option>
</md-select>
我也试过这个也行不通:
<md-select id="modelYearDropdown">
<md-option *ngFor="let modelYear of modelYearList" [value]="modelYear.value" id = "{{index}}" >
{{ modelYear.viewValue }}
</md-option>
</md-select>