I am trying to select a city depending on a certain country with AngularJS.
PROBLEM: The problem is that when I select the country and then the city, the value of the country is erased from the input. Note: Do not delete the entire object until after selecting a city and selecting the country again, there if you delete the entire object.
Any solution would be very helpful. Thank you very much
So I have the country code
function CargarListaRMOPaises() {
if ($route.current.loadedTemplateUrl.indexOf("Crear.html") > 0 ||
$route.current.loadedTemplateUrl.indexOf("Editar.html") > 0) {
RMOPaisService.getListaRMOPaises().then(function(e) {
$scope.listaRMOPaises = e.data;
});
}
}
So I have the city code
/* Carga los paises dependiendo de la ciudad */
$scope.CargarPaisesPorCiudad = function() {
if ($route.current.loadedTemplateUrl.indexOf("Crear.html") > 0 ||
$route.current.loadedTemplateUrl.indexOf("Editar.html") > 0) {
if ($scope.labelSeleccionePais) {
$scope.disableCiudad = true;
}
RMOCiudadService.getListaRMOCiudadesPorPais($scope.solicitud.Ciudad.Pais).then(function(e) {
$scope.disableCiudad = false;
$scope.listaRMOCiudades = e.data;
});
}
};
This is the object when it is full
{
"Id": 1,
"Nombre": "Medellin",
"IdPais": 1,
"Pais": {
"Id": 1,
"Nombre": "Colombia"
}
}