I have a problem in my angular app that says ERROR TypeError: Cannot read property 'name' of undefined but the projects.name is displaying. How can i get rid of the error in the console.log. The data contains an object.
ngOnInit() {
this.route.params
.subscribe((params: Params) => {
this.id = +params['id'];
this.projectsService = this.injector.get(ProjectsService);
this.projectsService.getProject(this.id)
.subscribe(
(data:any) => {
this.projects = data;
console.log(data);
},
error => {
alert("ERROR");
})
});
}