angularjs - 忽略列表中的空值
问题描述
我正在使用 ng-options 迭代对象列表,并在 UI 组件(下拉选择)中显示列表中的第一个值作为empty
值。如何忽略要显示的列表中的空值。
请在下面找到我的代码。另外,我正在我的 JSP 文件中编写此代码。
<select class = "form-control" form-control id = "lenProperty" ng-model = "bank.lendPropertyId"
ng-options="lenProperty.id
as lenProperty.lendPropertyName for lenProperty in lenProperties">
</select>
解决方案
您可以通过更改创建的方式来忽略空值<select>
:
<select class = "form-control" id = "lenProperty" ng-model="bank.lendPropertyId">
<option ng-repeat="lenProperty in lenProperties" ng-show="lenProperty.lendPropertyName">{{lenProperty.lendPropertyName}}</option>
</select>
推荐阅读
- javascript - 为什么我的 ajax 调用在第二次调用时使页面无响应?
- typescript - TypeScript 错误:属性不存在 - 虽然它存在
- java - Spring Rest 模板 Json 输出映射到对象
- python - 在 python webscraping 脚本中为错误创建异常
- selenium - 如何在浏览器堆栈上禁用 Ipad/Iphone 的 Safari 跨源请求?
- java - 列出java中匹配单词的所有下一个单词
- http - Logstash 过滤器 Http 错误请求错误 (ELK)
- video-streaming - HTML 视频:以块(流?)而不是单个文件的形式交付文件
- c# - 使用 Form 应用程序更改记录器的路径并使用 C# 将其实现为服务
- javascript - 在反应中调用作为道具传递的方法