Ng-hide在数据列表Angular中不起作用

404*_*und 5 datalist angularjs ng-hide

<body ng-app>
<datalist id="dataList">
  <select id="select">  
    <option ng-repeat="val in temp" ng-hide="true"  >{{val}}</option>
  </select>
</datalist>                            
<input  list="dataList"   ng-model="fromLocation"  />
</body>
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/awnqm/284/ 这是小提琴,我有一个简单的数据主义者和一个输入(使用该数据主义者).为什么ng-hide in options标签不起作用.

Gos*_*ten 4

ngHide 不适用于选项。您需要使用 ngIf。但是,它可以从 Angular 1.1.5 开始使用(Angular 1.1.5 引入了 ngIf 指令)。因此,请更新您的 Angular 版本并使用 ngIf 来解决该问题。看

<body ng-app>
<datalist id="dataList">
  <select id="select">  
    <option ng-repeat="val in temp" ng-if="false"  >{{val}}</option>
  </select>
</datalist>                            
<input  list="dataList"   ng-model="fromLocation"  />
</body>
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/Gosha_Fighten/awnqm/288/

ngHide 只是将display: noneCSS 应用于对选项不起作用的元素。例如,[IE11、Win7] OPTION 标记上的“display: none”将被忽略。ngIf 根本不渲染元素。