1
Good night, I’m not able to carry a select in the Angularjs! It does not load, it is blank. I’ll post the code, if anyone can help me thank you!! Controller:
<script>
angular.module("cadastroMedico", []);
angular.module("cadastroMedico").controller("cadastroMedicoController", function ($scope, $http){
$scope.app = "Cadastro de paciêntes";
$scope.pacienteEspe = [
];
var pacienteEspecial = function (){
$http.get("http://localhost:27623/api/amb/Diseases/TESTES%20CUTANEOS%20DE%20LEITURA%20IMEDIATA").then(function (data) {
$scope.pacienteEspe = data;
console.log(data);
});
};
pacienteEspecial();
});
</script>
index.html:
<select class="form-control" ng-model="paciente.pacienteEspe" ng-options="pacienteEsp.Procedimento_tuss for pacienteEsp in pacienteEspe">
<option value="">Selecione uma opcão</option>
</select>
it does not load, it is as if the data were there, but it has nothing! I have tried everything.. If anyone can help it..
Could show an example of JSON returned by API?
– OnoSendai
[ { "Id_amb92": 79, "Cod_amb92": "19010117", "Procedure_amb92": "IMMEDIATE READING SKIN TESTS", "Cod_tuss": "41401425", "Procedimento_tuss": "CONTACT TESTS - UP TO 30 SUBSTANCES", "Ch": "60" } ] Obs: when I display only the array {{patientEspe }} it shows me just that! And some information as API response in case 200.
– leonardo barussi
@leonardobarussi Can you post on your question how is the JSON received from the server-side? I mean, it being shown on the console in the browser’s network tab, or even directly in the browser by calling the URL.
– Jéf Bueno
$scope.pacienteEspe = data.data;
– Jéf Bueno
@jbueno worked out! rapaaaaaaaaaz, it was almost 2 days banging head with this problem! Thank you very old!
– leonardo barussi
All right!! @jbueno Voce could explain to me why I had to repeat the date?
– leonardo barussi
Yes, look at the
console.log
. That is the return of the functionget
, the data returned from the server-side is in the propertydata
of this return. It would be better if you gave a more descriptive name, asresponse
or another equivalent. Do you understand? This object represents the entire answer and not only the data, the data is part of the answer.– Jéf Bueno