Angular JS ng-options 返回 “?对象:005 ?
Angular JS ng-options returns "? object:005 ?"
我到处搜索过,很难说我做错了什么。我正在尝试使用控制器中的值填充选择组件
我的控制器代码段
$scope.sTypes=
[
{name:'PGD',id:1},
{name:'MSC',id:2},
{name:'PHD',id:3},
{name:'DBA',id:4}
]
$scope.selectedType={};
我的网页选择
<select ng-model="selectedType" ng-option="sType.name for sType in sTypes">
<option>--- Select Scholarship ---</option>
</select>
正在渲染的内容
<select
ng-model="selectedType"
ng-option="sType.name for sType in sTypes"
class="ng-pristine ng-valid">
<option value="? object:005 ?"></option>
<option value="--- Select Scholarship ---">
--- Select Scholarship ---
</option>
</select>
任何帮助将不胜感激,因为这开始惹恼我。
我自己还没有看到确切的事情,但我发现将value=""
添加到空选择选项中可以工作:
<select ng-model="selectedType" ng-option="sType.name for sType in sTypes">
<option value="">--- Select Scholarship ---</option>
</select>
如果 ng-model
为 null,这将是默认选择选项。
因此,我会像上面一样配置 html,然后像这样初始化selectedType
:
$scope.selectedType=null;
相关文章:
- 使用JS将数组转换为json对象
- 查看JS对象的所有键,甚至是getter定义的键
- 在URL中传递JS对象
- 为什么要包装每一个原型“;类“;JS中具有匿名函数的对象
- 当属性不一致时,如何根据属性对JS对象列表进行排序
- Node.js中的JavaScript原型对象效率
- 如何使用自定义功能覆盖时间轴对象.js时间轴对象的_repaintMinorText
- 如何在第三轴上旋转 3D 对象.js
- 三个中是否有容器类型对象.js来转换一组子对象
- 从 JSON 对象 - JS 周围删除双引号
- 删除对象JS中的节点
- 在对象数组中搜索非空对象JS
- 按未定义的值从数组中选择对象?JS
- 递归循环,直到我们'重新处理对象[JS]
- 向窗口对象-js添加新属性时得到通知
- 如何包含对象/关联数组到对象(js)
- 加载依赖于页面的面向对象JS属性的最好方法是什么?
- 合并新的数组对象到现有的对象js
- 获取带有下划线的数组中的对象.js
- 在带有下划线的嵌套集合中查找对象.js