Resolved: NgFor doesn’t display data 0 By Isaac Tonny on 17/06/2022 Issue Share Facebook Twitter LinkedIn Question: Hi i have the project with spring boot, sql, angular. I have relations with one to many and I dont know how to display the second object in component html. My Componnent: @Component({ selector: 'app-project', templateUrl: './project.component.html', styleUrls: ['./project.component.css'] }) export class ProjectComponent implements OnInit { public project: Project[]=[]; public editProject!:Project; public deleteProject!:Project; public teams!:Teams[]; title:any; constructor(private projectService: ProjectService, private _rotue:Router) { } ngOnInit(): void { this.getProject(); } public getProject(): void { this.projectService.getProject().subscribe( (response) => { this.project = response; console.log(this.project); }, (error: HttpErrorResponse) => { alert(error.message); } ); My Html: Name of Project: {{projects?.name}} Name of team: {{projects?.teams.name}} My Json get: { "id":"34, "name":"Projekt", "priority":"wysoki", "teams":[{ "id":2, "name":"DruzynaA", "leader":"Wojtek" }]} And the “teams” does not display, if i change that to project.teams is display [object Object] also i try with | async but it not helped. I am asking for help, I will be grateful Answer: It looks like Teams is an array so you need to specify an index. Name of team: {{projects?.teams[index].name}} Also, some notes. you are using ngfor for project which looks like an object. you probably meant to do it for Teams? If you have better answer, please add a comment about this, thank you! angular display html spring spring-boot Share. Facebook Twitter LinkedIn Related Posts Resolved: In a Pinescript v5 Strategy why is my bool not working?02/04/2023 Resolved: net::ERR_HTTP2_PROTOCOL_ERROR by http get request angular 15.202/04/2023 Resolved: How do I stop the command from happening if the requirements for it to work aren’t sert Discord.js02/04/2023 Leave A Reply Save my name, email, and website in this browser for the next time I comment.
Resolved: How do I stop the command from happening if the requirements for it to work aren’t sert Discord.js02/04/2023