在select if中设置空值如果为空则选择AngularJS

时间:2017-11-15 18:49:24

标签: angularjs

有人可以告诉我如何制作空值,如果在选择列表中没有任何内容,则显示“不适用”

demo

https://codepen.io/Turqus/pen/wPrKrr?editors=1010

模板

    <div ng-app="test" ng-controller="select">
  <select class="form-control" ng-model="selectedBoard" ng-change="changeBoard(selectedBoard)">
     <option ng-repeat="item in boards" value="{{$index}}">{{$index}}</option>   
 </select>

 <select class="form-control" ng-model="selectedList">
   <option ng-repeat="item in downloadedLists" value="{{$index}}">{{$index}}</option> 
 </select>                  
</div>

3 个答案:

答案 0 :(得分:3)

<option ng-repeat=" item in downloadsLists" >{{$index || "n/a"}}</option>

答案 1 :(得分:0)

sudo apt-get install clang

clang -v //Now see installed version

答案 2 :(得分:0)

 <option value="">N/A </option>  
 <option ng-repeat="item in boards" value="{{$index}}">{{$index}}</option>