javascript - AngularJS instead of using two ng-show and two dropdowns Can I use one dropdown -


i want use 1 dropdown need satisfy both conditions.

<div ng-show="user == 'admin'">      <div class="col-md-8 col-sm-12 col-xs-12">          <select   ng-model="li"  >              <option  ng-repeat="li in list">{{li.name}}</option>          </select>      </div>  </div>   <div ng-show="user != 'admin'">      <div class="col-md-8 col-sm-12 col-xs-12">          <select   ng-model="li"  >              <option  ng-repeat="li in list|limitto:1">{{li.name}}</option>          </select>     </div>  </div> 

code in plunker

you can try this:

<div ng-if="user == 'admin'">         <div class="col-md-8 col-sm-12 col-xs-12">             <select ng-model="li">                 <option  ng-repeat="li in list">{{li.name}}</option>              </select>         </div>     </div>     <div ng-if="user != 'admin'">         <div class="col-md-8 col-sm-12 col-xs-12">             <select ng-model="li">                   <option  ng-repeat="li in list" ng-if="$first">{{li.name}}</option>             </select>         </div>     </div>  

use ng-if instead of ng-show , use ng-if="$first" rather putting limitto:1 filter.

here updated plunker url:http://plnkr.co/edit/cwc9prhqrulcky8umbse?p=preview


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -