Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 多个下拉列表的动态ng模型生成_Jquery_Angularjs - Fatal编程技术网

Jquery 多个下拉列表的动态ng模型生成

Jquery 多个下拉列表的动态ng模型生成,jquery,angularjs,Jquery,Angularjs,我需要根据mongodb集合中的数据动态生成多个下拉列表 { "_id" : ObjectId("58f4fdd4c9fc145b279a1cc9"), "_class" : "com.zwayam.common.rg.mongodb.MasterDataFields", "entityType" : "Company", "editableFields" : { "industry" : "mappingFields.industry",

我需要根据mongodb集合中的数据动态生成多个下拉列表

{
    "_id" : ObjectId("58f4fdd4c9fc145b279a1cc9"),
    "_class" : "com.zwayam.common.rg.mongodb.MasterDataFields",
    "entityType" : "Company",
    "editableFields" : {
        "industry" : "mappingFields.industry",
        "group" : "mappingFields.group"
    }
}
在上面的json中,object industry指的是表中的列名,mappingFields.industry指的是来自主列表ie的值

{
    "_id" : ObjectId("58edd50e44ae5483c2eb2f34"),
    "_class" : "zwayam.common.rg.mongodb.MasterDataMap",
    "fieldName" : "masterData",
    "mappingFields" : {
        "function" : [ 
            "Chartered Accountant/CPA", 
            "Chartered Accountant", 
            "Accounting", 
            "Tax", 
            "Company Secretary", 
            "Audit", 
            "Direct Sales Agent/Insurance Agents", 
            "Hotel / Restaurant", 
            "Content / Editors / Journalists", 
            "Finance", 
            "Consulting / Strategy / Corporate Planning"
        ],
        "industry" : [ 
            "Biotechnology/Pharmaceutical/Medicine", 
            "CRM/CallCentres/BPO/ITES/MedTrans", 
            "Educational/Training", 
            "Recruitment/Placement Agencies", 
            "Engineering/Projects", 
            "Entertainment/Media", 
            "Financial Services/Stockbroking"
        ],
        "group" : [ 
            "group 1", 
            "group 2", 
            "group 3", 
            "group 4", 
            "group 5", 
            "group 6", 
            "group 7"
        ],
        "scale" : [ 
            "scale 1", 
            "scale 2", 
            "scale 3", 
            "scale 4", 
            "scale 5", 
            "scale 6", 
            "scale 7"
        ],
        "type" : [ 
            "type 1", 
            "type 2", 
            "type 3", 
            "type 4", 
            "type 5", 
            "type 6", 
            "type 7"
        ]
    }
}
我能够填充列表,我已经从下面的代码中完成了

        <div class="col-sm-12 ats-display editCompany"
             ng-repeat="(key,value) in dataList">
            <label for="workflowDefination"
                class="control-label workflowLabel">
                {{key}}
            </label> 
            <select ng-model="CompanyFields.value" ng-click="getfield();"
                id="{{key}}" class="form-control" 
                ng-options="CompanyFields for CompanyFields in dataValueList.{{value}}" >
                <option value="" label="Select the value"></option>
            </select>
            {{CompanyFields}}
            <div class="col-sm-12" style="height: 17px;"></div>
        </div>

{{key}}
{{CompanyFields}}

但我不知道如何为这些下拉列表设置ng模型,并从每个下拉列表中获取用户选择的值。有谁能告诉我如何为上述需求设置动态ng模型吗?

我通过设置
ng model=“CompanyObj[key]”
解决了我的问题,其中
CompanyObj
是一个json对象

   <div class="col-sm-12 ats-display editCompany" ng-repeat="(key,value) in dataList">
    <label for="workflowDefination" class="control-label workflowLabel">{{key}}</label>
    <select ng-model="CompanyObj[key]" ng-click="getfield(CompanyFields[value]);" id="{{key}}" class="form-control" ng-options="CompanyFields for CompanyFields in dataValueList.{{value}}">
        <option value="" label="Select the value"></option>
    </select>
    {{CompanyFields}}
    <div class="col-sm-12" style="height: 17px;">

    </div>

</div>

{{key}}
{{CompanyFields}}

我们可以使用
$eval
解析对象中的表达式

JS:


{{key}}
 <div ng-repeat = "(key,value) in parentdata.editableFields" >
      {{key}}
    <select id="{{key}}" ng-model="selectedQuery"  ng-options="key as value for (key,value) in $eval('jsondata.'+value)">  
                <option value="" label="Select the value"></option> 
    </select>
    </div>