Reputation: 1
I have an API that sends a Json to me. But I don't know how to show it into my html. I know that I have to use Ngfor but it doesn't work. This is my code.
SaveData(){
var dataToSend2 = "Hola";
var dataToSend = {"num_personal":"419","anio_pago":"2022","periodo_pago":"09"};
console.log(dataToSend);
this.proveedor.saveData(dataToSend).subscribe(
(dataReturnFromService)=>{
this.dataFromService = (dataReturnFromService);
let obj = JSON.parse(this.dataFromService);
this.dataFromJson = obj;
console.log(obj);
}
)
}
This part gives me a Json with the data from my API, but I don't know how to use the Json "obj" to show it into the html
Upvotes: -1
Views: 37
Reputation: 929
you forgot to show your html code. but it should work if it looks like this:
<div *ngFor="let x of dataFromJson">
<span>{{x.label}}</td>
</div>
Upvotes: 1