以下是我根据ng-options选择国家/地区的代码,并根据ng-repeat获取标签:
<select ng-model="country" ng-options= "countryName.country for countryName in countryNames" ng-change="getCountry()">
</select>
<ul id="configPhoneTab" class="nav nav-tabs equipmentTab agenttabs">
<li class="active" ng-repeat= "configTab in config" val="configTab[0]">
<a href="#" data-toggle="tab">{{configTab.tabs}}</a>
</li>
</ul>
我在json文件中的标签是
[
{
"country": "India",
"tabs": [
{
"title": "India Number",
"type": [
"VOICE",
"FAX",
"VN"
],
"carrier": "L3",
},
{
"title": "Toll Free",
"type": [
"TF"
],
"carrier": "L3",
}
]
},
{
"country": "Aus",
"tabs": [
{
"title": "Aus Number",
"type": [
"VOICE",
"FAX",
"VN"
],
"carrier": "L3",
},
{
"title": "Toll Free",
"type": [
"TF"
],
"carrier": "L3",
}
]
}
如何根据国家/地区选择从json检索标签标题?
答案 0 :(得分:0)
你可以使用像[underscorejs]
(website address)这样的第三方库,并使用其中的一些函数检索所需的数据,例如_.where(...)
如果'_.fined(... )'
您的搜索所依据的数据透视表将是$scope.country
与您的<select>
代码绑定的<select ng-model="country" ng-options= ...
希望它有所帮助。