ng-selected inside of ng-repeat 不起作用 (AngularJS)
ng-selected inside of ng-repeat not working (AngularJS)
我正在尝试将值与我的 <select>
标签内的 "check" 和 <option>
标签进行比较,但找不到解决方案...
*这是一个管理页面,所以我已经有了 {{x.nivel}} 值。我只需要根据 ng-repeat
.
中的每个 "inscritos" 将其标记为 "selected"
求助:\
<li ng-repeat="x in inscritos | orderBy:'nome'">
<select>
<option ng-selected="(this.value)=={{x.nivel}}" value="Iniciante">Iniciante</option>
<option ng-selected="(this.value)=={{x.nivel}}" value="Intermediário">Intermediário</option>
<option ng-selected="(this.value)=={{x.nivel}}" value="Avançado">Avançado</option>
</select>
</li>
不要在js表达式中使用{{}}
:
<li ng-repeat="x in inscritos | orderBy:'nome'">
<select>
<option ng-selected="x.nivel=='Iniciante'" value="Iniciante">Iniciante</option>
<option ng-selected="x.nivel=='Intermediário'" value="Intermediário">Intermediário</option>
<option ng-selected="x.nivel=='Avançado'" value="Avançado">Avançado</option>
</select>
</li>
双花括号符号 {{ }}
用于将值与 html 元素绑定。请参阅 templates 文档。
我正在尝试将值与我的 <select>
标签内的 "check" 和 <option>
标签进行比较,但找不到解决方案...
*这是一个管理页面,所以我已经有了 {{x.nivel}} 值。我只需要根据 ng-repeat
.
求助:\
<li ng-repeat="x in inscritos | orderBy:'nome'">
<select>
<option ng-selected="(this.value)=={{x.nivel}}" value="Iniciante">Iniciante</option>
<option ng-selected="(this.value)=={{x.nivel}}" value="Intermediário">Intermediário</option>
<option ng-selected="(this.value)=={{x.nivel}}" value="Avançado">Avançado</option>
</select>
</li>
不要在js表达式中使用{{}}
:
<li ng-repeat="x in inscritos | orderBy:'nome'">
<select>
<option ng-selected="x.nivel=='Iniciante'" value="Iniciante">Iniciante</option>
<option ng-selected="x.nivel=='Intermediário'" value="Intermediário">Intermediário</option>
<option ng-selected="x.nivel=='Avançado'" value="Avançado">Avançado</option>
</select>
</li>
双花括号符号 {{ }}
用于将值与 html 元素绑定。请参阅 templates 文档。