0
在我的html,我有以下的标记空白值,而不是价值
<div class="col-md-8">
@*@Html.DropDownList("templateTypes", (IEnumerable<SelectListItem>)ViewBag.TemplateTypes, new { @class = "form-control", ng_model = "currentTemplate.tmplType" })*@
<select class="form-control" name="templateTypes" id="templateTypes"
ng-model="currentTemplate.tmplType"
ng-options="t.value as t.text for t in templateTypes"></select>
</div>
的tmplType在模型字节。值和文本是字符串。当我查看我的表单时,选择变为空白。如果我选择一个不同的值(只有2个选项),我可以看到这个值正确地进入数据库。但是,在重新加载表单后,select选项仍显示为空白。这里可能是什么问题?
重装后哪个值有你的currentTemplate.tmplType? – 2014-08-29 20:38:52
是'currentTemplate.tmplType == t.value'?不知道我是否正确理解你,当'tmplType是字节'和'值和文本是字符串'时,你必须解析其中的一个。 – nilsK 2014-08-29 21:32:14
在谷歌Chrome开发人员工具,我看到以下内容: $ scope.currentTemplate.tmplType $ scope.templateTypes [对象选择:真正的文字: “通过” 值: “1” 所以,tmplType为1,值是“1”。我不知道为什么它下拉显示空白是有区别的 – Naomi 2014-08-29 21:56:58