<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>
http://jsfiddle.net/awnqm/284/
这是小提琴,我有一个简单的数据主义者和一个输入(使用该数据主义者).
为什么ng-hide in options标签不起作用.
解决方法
ngHide不适用于选项.你需要使用ngIf.但是,它可以从Angular 1.1.5(
Angular 1.1.5 introduced the ngIf directive)获得.因此,更新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>
http://jsfiddle.net/Gosha_Fighten/awnqm/288/
ngHide简单地将display:none CSS应用于不适用于选项的元素.例如,[IE11,Win7] “display: none” on OPTION tag is ignored.ngIf根本不渲染元素.