Angularjs:采用NG-选项时如何包括选择空选项 [英] Angularjs: How to include empty option in select when using ng-option

查看:399
本文介绍了Angularjs:采用NG-选项时如何包括选择空选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以添加空的选项,在刚开始的时候我用NG-选项来提供的,不包括空单选项predefined列表?

在玉的一个例子

 选择(NG-模型=property.Value,NG-选项=item.Value作为item.Name为项property.Choices)


解决方案

只是选择的内空值增加一个选项。

 选择(NG-模型=property.Value,NG-选项=item.Value作为item.Name为项property.Choices)
  选项​​(价值=)

下面是一个例子 - http://jsfiddle.net/sseletskyy/uky9m/1/

How can I add empty option in the beginning when I use ng-option to provide predefined list of options which doesn't include empty one?

An example in jade

select(ng-model="property.Value", ng-options="item.Value as item.Name for item in property.Choices")

解决方案

Just add an option with empty value inside of the select.

select(ng-model="property.Value", ng-options="item.Value as item.Name for item in property.Choices")
  option(value="")

Here's an example - http://jsfiddle.net/sseletskyy/uky9m/1/

这篇关于Angularjs:采用NG-选项时如何包括选择空选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆