AngularJS ng-selected
指令
AngularJS 實(shí)例
獲取選中的選項(xiàng):
點(diǎn)擊復(fù)選框選擇 BMW 選項(xiàng):
<input type="checkbox" ng-model="mySel">
<p>我喜歡的車:</p>
<select>
<option>Volvo</option>
<option ng-selected="mySel">BMW</option>
<option>Ford</option>
</select>
<input type="checkbox" ng-model="mySel">
<p>我喜歡的車:</p>
<select>
<option>Volvo</option>
<option ng-selected="mySel">BMW</option>
<option>Ford</option>
</select>
嘗試一下 ?
定義和用法
ng-selected 指令用于設(shè)置 <select> 列表中的 <option> 元素的 selected 屬性。
ng-selected
屬性的表達(dá)式返回 true 則選項(xiàng)被選中。
語(yǔ)法
<option ng-selected="expression"></option>
<option> 元素支持該指令。
參數(shù)值
值 | 描述 |
---|---|
expression | 如果表達(dá)式為 true 則選項(xiàng)被選中 |
更多建議: