Good day I have the following problem, when I consume my service REST from the angle he brings me the 3 types of documents, but when painting them on the front, he shows me at the beginning a space.
This is my html:
<label for="documento">Documento de Identidad*</label>
<select ng-model="contenido.tipoDocumento" ng-model="user.tipoDocumento" name="tipoDocumento" >
<option ng-repeat="option in listaTiposDoc" value="{{option.nombre}}">{{option.nombre}}</option>
</select>
part of the service in the controller:
servicioRest.getParametros().then(function (data) {
$scope.config.parametros = data;
//Obtenemos los tipos de documento
$scope.config.urlService = endPoint+$scope.config.parametros.contexto;
servicioRest.getTiposDocumento($scope.config).then(function(dataDocumentos){
$scope.listaTiposDoc = dataDocumentos;
});
});
When I do a debug he shows me what he brings from the service like this:
but the result is a space at the beginning that I do not know how to remove it:
Thanks.
Media Solution:
I solved it by setting from the beginning, the value of:
$scope.contenido.tipoDocumento = 'CC';
From the controller, so it loads without spaces, it is worth clarifying that the solution is for when said value is within the options of the select.
$scope.contenido.tipoDocumento = 'CC';
servicioRest.getParametros().then(function (data) {
$scope.config.parametros = data;
//Obtenemos los tipos de documento
$scope.config.urlService = endPoint+$scope.config.parametros.contexto;
servicioRest.getTiposDocumento($scope.config).then(function(dataDocumentos){
$scope.listaTiposDoc = dataDocumentos;
});
});
I do not know if it will be the best practice but it is working OK.