下面是我的代码,用于根据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中检索选项卡标题?
发布于 2014-01-07 05:25:01
您可以使用像[underscorejs] (website address)这样的第三方库,并使用它的一些函数来检索所需的数据,例如_.where(...) if '_.fined(...)‘
您的搜索将基于绑定到您的<select>标签(<select ng-model="country" ng-options= ...)的$scope.country。
很抱歉,我无法立即提供任何工作演示,因为我是从移动设备回答的。
希望这能帮上忙。
https://stackoverflow.com/questions/20957116
复制相似问题