0

I got error from ERROR TypeError: "_co.dashboard is undefined" when I try to call dashboard.all_interviewed in html.

In My dashboard.component.ts

dashboard: Dashboard;

    getDashboard() {
      this.dashboardService.getDashboard().subscribe(
        res => {
            this.dashboard = res;
         }
      )
    }

In Dasboard Class

export class Dashboard {
   all_interviewed: number;
}

dashboard.component.html

<h2>{{ dashboard.all_interviewed }} </h2>

I got this error in console log.

ERROR TypeError: "_co.dashboard is undefined" View_DashboardComponent_0 DashboardComponent.html:208 Angular 32 RxJS 5 Angular 8 DashboardComponent.html:203:11

4
  • Check spelling in dashboard.component.html Commented Jul 26, 2019 at 11:23
  • dasboard spell mistake. In component it is dashboard. Commented Jul 26, 2019 at 11:24
  • please change that line Commented Jul 26, 2019 at 11:27
  • 2
    Hello i don't know why but i can't write answer. this is the shortest snippet: dasboard?.all_interviewed Commented Jul 26, 2019 at 11:36

2 Answers 2

0

Try the following code,

<h2 *ngIf = "dashboard">{{ dashboard.all_interviewed }} </h2>
Sign up to request clarification or add additional context in comments.

Comments

0

Call getDashboard() on ngOnInit() and then try this:

<div *ngIf = "dashboard">
   <h2>{{ dashboard.all_interviewed }}</h2>
</div>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.