I am new to Angular 5 and I am currently trying to display data from a database to a view. But I am definitely doing something wrong since the view is just getting [object object]. I would like some help in what I am doing wrong.
Thank you.
The View
I am new to Angular 5 and I am currently trying to display data from a database to a view. But I am definitely doing something wrong since the view is just getting [object object]. I would like some help in what I am doing wrong.
Thank you.
The View
To display the students (not like JSON) , you need to call object.property , in your case user.first_name, user.last_name, user.user_type. Your component HTML :
<h1>CDM Student</h1> <div *ngFor="let user of users"> {{user.first_name}} {{user.last_name}} </div>code here Also in your API http://localhost:3000/api/users , you shouldn't return the PASSWORD in the JSON (be very careful with this kind of information)
your Code is ok . just add angular json pipe. Have you seen https://angular.io/api/common/JsonPipe
The Component's HTML
<h1>CDM Student</h1> <div *ngFor="let user of users"> {{user | json}} </div>code here maybe it's helpful for you . Thank you