@Injectable({
providedIn: 'root'
})
export class PatientService {
listpatient;
constructor(private httpClient:HttpClient) {
this.httpClient.get("http://localhost:8010/patients").subscribe(data=>{this.listpatient=data;},err=>{console.log(err);})
}
}
---------------------------------------
@Component({
selector: 'app-pat',
templateUrl: './patient.component.html',
styleUrls: ['./patient.component.css'],
})
export class PatientComponent implements OnInit {
@Input()listpatient;
constructor(patient:PatientService){
this.listpatient=patient.listpatient;
}
ngOnInit() {}
}
---------------------------------------
<table *ngIf="listpatient" class="table">//he don't enter in the table
<tr>
<th>ID</th><th>Nom</th><th>Prenom</th> <th></th>
</tr>
<tr *ngFor="let f of listpatient">
<td>{{f.id}}</td>
<td>{{f.nom}}</td>
<td>{{f.prenom}}</td>
<td routerLink="patientdetail" routerLinkActive="active" type="button" class="btn btn-light">Obtenir les infos</td>
</tr>
</table>
我从spring加载我的患者列表,但我有一个问题,它没有显示我的列表,我想我不能将数据发送到html。它不会进入*ngIf
https://stackoverflow.com/questions/56226069
复制相似问题