gpt4 book ai didi

angularjs - 在 ng-repeat 和 ng-change 中传递两个值

转载 作者:行者123 更新时间:2023-12-02 23:09:53 28 4
gpt4 key购买 nike

Controller :

var response = {
"json": {
"response": {
"servicetype": "100",
"functiontype": "101",
"statuscode": "success",
"data": [
{
"countryid": 1,
"countryname": "India",
"countrycode": "91",
"currencyname": "Indian rupee",
"currencycode": "INR",
"latitude": "21.7679",
"longitude": "78.8718"
}
]
}
}
}

$scope.country = response.json.response.data;

HTML:

 <select name="Country" class="form-control1 drop countries" required  ng-model="model.country" placeholder="Select" value="India"  ng-change="getState(model.country);">
<option value="" disabled selected> Country*</option>
<option ng-repeat="item in country track by $index" value="{{item.countryid}}">{{item.countryname}}</option>
</select>

我想传递国家名称和国家ID来获取州列表,需要解决方案。我只能传递国家/地区 ID。需要帮助。

最佳答案

<select ng-model="country" required
ng-options="c as c.countryname for c in country track by c.countryid" ng-change="getState(country.countryid, country.countryname);" >
<option value="">Country*</option>
</select>

使用ng-options,您将获得国家/地区模型中的所有值

关于angularjs - 在 ng-repeat 和 ng-change 中传递两个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45936861/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com