Estou usando a função ng-options e está listando de forma correta, só não está aparecendo o valor marcado como default: selected
Código:
<select class="form-control"
ng-model="genericCustomersViewModel.customer.addresses[0].stateId"
ng-options="state.id as state.initials for state in
genericCustomersViewModel.allStates track by state.id"
ng-change="genericCustomersViewModel.getCityByState(0)"
ng-selected="genericCustomersViewModel.customer.addresses[0].stateId">
</select>`
AllStates
[{ "id":1,
"description":"ACRE",
"initials":"AC",
"specificCountryCode":12,
"countryId":30 },
{ "id":2,
"description":"ALAGOAS",
"initials":"AL",
"specificCountryCode":27,
"countryId":30 },
{ "id":3,
"description":"AMAPÁ",
"initials":"AP",
"specificCountryCode":16,
"countryId":30}]
Customer
{ "rg":null,
"inscricaoMunicipal":null,
"inscricaoEstadual":null,
"cpfCnpj":"13",
"inscricaoEstadualIndicator":null,
"phoneNumber2":null,
"phoneNumber3":null,
"emailNfe":null,
"emailBoleto":null,
"branchesIds":[],
"id":12,
"name":"Razão social",
"companyName":null,
"mainPhoneNumber":null,
"mainEmail":null,
"site":null,
"entityType":1,
"isActive":true,
"isDeleted":false,
"contacts":[],
"addresses":[
{ "id":1,
"description":null,
"addressType":0,
"postalCode":93700,
"address1":"Balduino Dreger",
"address2":"Não tem",
"number":345,
"district":"Bela Vista",
"cityId":null,
"stateId":20,
"countryId":null,
"entityId":12
},
{ "id":2,
"description":"Comercial",
"addressType":0,
"postalCode":93700,
"address1":"Rua dos bobos",
"address2":"Num tem",
"number":666,
"district":"Centro",
"cityId":4057,
"stateId":19,
"countryId":null,
"entityId":12
}
]
}