Javascript 用角度选项项具体化css选择问题
我正在尝试在我的项目中使用物化css。我从服务器端加载select项的可选元素,当数据到达时,我使用以下语句更新select控件:Javascript 用角度选项项具体化css选择问题,javascript,jquery,html,select,materialize,Javascript,Jquery,Html,Select,Materialize,我正在尝试在我的项目中使用物化css。我从服务器端加载select项的可选元素,当数据到达时,我使用以下语句更新select控件: $("#surveyTypeId").material_select(); 生成的列表看起来在列表顶部(图像上的灰色区域)包含一个额外的空元素。 当我尝试选择一个项目时,选项值似乎发生了变化。当我选择灰色区域时,我有“Classec调查”项目的值,当我在UI上选择“经典调查”时,我有“关于候选人的参考调查”的值 生成的源是: <div c
$("#surveyTypeId").material_select();
生成的列表看起来在列表顶部(图像上的灰色区域)包含一个额外的空元素。
当我尝试选择一个项目时,选项值似乎发生了变化。当我选择灰色区域时,我有“Classec调查”项目的值,当我在UI上选择“经典调查”时,我有“关于候选人的参考调查”的值
生成的源是:
<div class="input-field col s10 m10 l10 no-padding">
<label for="surveyTypeId">Select survey type</label>
<div class="select-wrapper select-material ng-pristine ng-untouched ng-invalid ng-invalid-required initialized">
<span class="caret">▼</span>
<input class="select-dropdown" readonly="true"
data-activates="select-options-995977c5-5d47-4511-fb6a-6a51cbc1cfb6" value=""
type="text">
<ul style="width: 712px; position: absolute; top: 0px; left: 0px; opacity: 1; display: none;" id="select-options-995977c5-5d47-4511-fb6a-6a51cbc1cfb6" class="dropdown-content select-dropdown">
<li class="active"><span></span></li>
<li class=""><span>Classic Survey</span></li>
<li class=""><span>Referrer Survey about Candidate</span></li>
<li class=""><span>Project Manager Survey about Candidate</span></li>
</ul>
<select required="required" id="surveyTypeId" class="select-material
ng-untouched initialized ng-dirty ng-valid-parse ng-valid ng-valid-required" name="surveyTypeId" ng-model="survey.SurveyTypeId" ng-required="true">
<!-- ngRepeat: wl in lookups.SurveyTypesLookupValues -->
<option class="ng-binding ng-scope" ng-repeat="wl in lookups.SurveyTypesLookupValues" value="1">Classic Survey</option>
<!-- end ngRepeat: wl in lookups.SurveyTypesLookupValues -->
<option class="ng-binding ng-scope" ng-repeat="wl in lookups.SurveyTypesLookupValues" value="2">Referrer Survey about Candidate</option>
<!-- end ngRepeat: wl in lookups.SurveyTypesLookupValues -->
<option class="ng-binding ng-scope" ng-repeat="wl in lookups.SurveyTypesLookupValues" value="3">Project Manager Survey about Candidate</option><!-- end ngRepeat: wl in lookups.SurveyTypesLookupValues -->
</select>
</div>
</div>
选择测量类型
▼
- 经典调查
- 关于候选人的推荐人调查
- 关于候选人的项目经理调查
经典调查
关于候选人的推荐人调查
项目经理关于候选人的调查
正如你所看到的,在最初的选择控件中,我只有3个选项
你知道我为什么在materialize生成的列表中有空项吗?或者如何处理掉那些空的东西?或者至少如何修正值的偏移?
谢谢
已解决:
在仔细检查角度生成之后,结果是,最初生成了一个空项,正如您所说的。在这之后,angular更新修复了这个问题,但materialize列表生成仍然保留了该项。(虽然我不明白为什么?)。感谢@shashanka n的建议。这个问题是重复的,我不认为这是同一个问题。在我的例子中,角度生成的列表只包含3个元素。您只能在
中看到3个
,这很好。我的问题是
元素有4个
元素。由materialize JS生成。正确的角度项目和不正确的物化项目之间的差异确实是我的问题。@shashanka n:在仔细检查角度生成之后,结果发现,最初生成的是一个空项目,正如您所说的。在这之后,angular更新修复了这个问题,但materialize列表生成仍然保留了该项。(虽然我不明白为什么?)。谢谢你的主意。