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>
I wanted to pass both the countryname and countryid to fetch list of states , need solution . I could just pass only country id. Need assistance.
<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>
Use ng-options, you will get all values in country model
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With