AngularJS ng-selected 指令
AngularJS 實例
獲取選中的選項:
點擊複選框選擇BMW 選項:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body ng-app="">點擊複選框選擇BMW 選項:<input type="checkbox" ng-model="mySel"><p>我喜歡的車:</p><select> <option>Volvo</option> <option ng-selected="mySel">BMW</option> <option>Ford</option> </select></body></html>
定義和用法
ng-selected 指令用於設置<select> 列表中的<option> 元素的selected 屬性。
ng-selected 屬性的表達式返回true 則選項被選中。
文法
<option ng-selected="expression"></option>
<option> 元素支持該指令。
參數值
| 值 | 描述 |
|---|---|
| expression | 如果表達式為true 則選項被選中 |
以上就是對AngularJS ng-selected指令的基礎資料整理,後續繼續整理,謝謝大家的支持!