过去几周我一直在使用 AngularJS 和 X-editable,让我困扰的一件事是选择选项提供了一个空选项作为第一个 child 。
这是 HTML
<span editable-select="curuser.roles" e-name="roles" e-ng-options="role as role.name for role in roles">
{{ showRoles() }}
</span>
这是输出的 HTML :
<select name="roles" ng-options="role as role.name for role in roles">
<option value="?" selected="selected"></option>
<option value="0">Admin</option>
<option value="1">Company</option>
<option value="2">Manager</option>
</select>
我需要做什么才能摆脱这个空选项?
这里正在工作JSFiddle
最佳答案
你还没有选择答案,所以我想我会提交我为其他有类似问题的人工作的 fiddle 。我更新了你的 editable-select 和你的 e-ng-options。这是更新的 fiddle http://jsfiddle.net/7e7kk/22/
editable-select="roles[0].value"
ng-options="role.value as role.name for role in roles"
关于javascript - 从 X-editable Select 中删除空选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24825471/