4
I have a problem presenting my list of items from my select.
In this my HTML I use ng-repeat to list all items, and when my screen is loaded my first and only item is: {{list name.}}, when I click on this item {{list name.}, ai loads the list of correctly.
<select data-placeholder="Escolha uma Empresa/Filial" multiple chosen
style="width: 100%;"
ng-model="filtroRequisicao.codigoSistemaUsuariosFiliais"
required>
<option ng-repeat="list in lista" ng-value="list.id">
{{list.name}}
</option>
</select>
Angularjs:
$scope.lista = [{}];
//Carrega as Filiais dos Cooperados
$scope.loadFiliais = function () {
var usuario = localStorage.getItem("usuarioAutenticado");
var objetoUsuario = {};
objetoUsuario = JSON.parse(usuario);
$http({
method: 'PUT',
url: '/getFiliais',
data: objetoUsuario
}).then(function (response) {
$scope.lista = response.data;
console.log($scope.lista);
},
function (response) {
console.log(response.data);
$scope.showNoty('Nenhum dado encontrado.', 'information');
});
};
$scope.loadFiliais();
If anyone can give you a hint, I’d appreciate it!
the user object has user credentials?
– Lucas
Yes, the object has the credentials of the user who is logged in, that object I pass to the send (PUT) and receive the list of affiliates of that user.
– user11890
Be careful, because storing it in the client is not safe
– Lucas
And what is the best practice for it?
– user11890
Server-side cookies, validation with Oauth2 (confusing, more secure medium), Digest, etc... Give a search in these paradigms : )
– Lucas
Okay, I’ll look into it! As for the current problem, do you have any tips? Thank you
– user11890
have tried to fill this select otherwise, such as ngOptions?
– CleristonDantas