Javascript 在运行时创建下拉列表,并在此之后绑定下拉列表值-不工作的选项
我使用AngularJs在运行时生成下拉列表。我还想用它绑定相应的选项,这些选项将根据创建的下拉列表类型生成Javascript 在运行时创建下拉列表,并在此之后绑定下拉列表值-不工作的选项,javascript,angularjs,Javascript,Angularjs,我使用AngularJs在运行时生成下拉列表。我还想用它绑定相应的选项,这些选项将根据创建的下拉列表类型生成 <div class="form-group" ng-repeat="attrib in col1Attribs"> <label class="control-label" for="txtCode">{{attrib.displayText}}</label> <select class="form-control"
<div class="form-group" ng-repeat="attrib in col1Attribs">
<label class="control-label" for="txtCode">{{attrib.displayText}}</label>
<select class="form-control"
ng-options="item.configValue for item in configOptions(attrib.configType)" />
</div>
编辑:
这是参数类型为'Status'时的数据
我能够使用下面的代码完成我的任务,但不使用ngOptions
<div class="form-group" ng-repeat="attrib in col1Attribs">
<label class="control-label" for="txtCode">{{attrib.displayText}}</label>
<select class="form-control">
<option ng-repeat="c in configOptions(attrib.configType)" value="{{c.configId}}">
{{c.configValue}}</option>
</div>
</div>
试试这个我看不到你剩下的代码。下面是如何创建下拉列表的一个片段:
<select data-ng-options="e.description for e in configOptions" data-ng-model="selectedOption" />
演示:您可能正在尝试此功能 用作
configId添加为选项值,configValue添加为显示值。SmartCache中的数据是什么样子的?SmartCache有一个键值对,即SmartCache。putStatus,MyJSONObject我猜您想基于类型创建多个下拉列表?@创新:正在使用col1Attribs创建多个下拉列表。我想根据下拉列表类型绑定这些下拉列表。此处的e.name是什么。提供的数据不包含名称当数据为静态时,此绑定将起作用。但是,在我的例子中,这个配置选项需要一个参数,根据该参数,数据将绑定到下拉列表。您可以发布您尝试的plnkr.co/edit或jsfiddle.com吗
<div class="form-group" ng-repeat="attrib in col1Attribs">
<label class="control-label" for="txtCode">{{attrib.displayText}}</label>
<select class="form-control">
<option ng-repeat="c in configOptions(attrib.configType)" value="{{c.configId}}">
{{c.configValue}}</option>
</div>
</div>
<select data-ng-options="e.description for e in configOptions" data-ng-model="selectedOption" />
<select class="form-control"
ng-options="item.configId as item.configValue for item in configOptions(attrib.configType)" />