kmar akrout
kmar akrout

Reputation: 365

Fill Chart dynamically with variables from Component

i am new to Angular so i think i'm missing something.

i have 3 variables in my component, those variables are being filled after calling .subscribe method on an observable object.

like this

this.interRetard = this.technicienService.getInterRetard(id).subscribe(data => {
  this.interRetard = data;
});

the interRetard variable contains a number, i can display its value in the html by doing {{interRetard}} .

the problem is that when i try to display it with console.log() it says :

Subscriber {closed: false, _parent: null, _parents: null, _subscriptions: Array(1), syncErrorValue: null, …}

and i need it to give me the exact value like it is displaying it in the html so i can assign it to the chart like this

public doughnutChartData:number[] = [this.interRetard ,  5, 10];

Thank you.

Upvotes: 0

Views: 162

Answers (1)

alokstar
alokstar

Reputation: 499

This should work:

   this.technicienService.getInterRetard(id).subscribe(data => {
      this.interRetard = data;
      console.log(this.iterRetard);
      this.myFunction(this.iterRetard) or this.myFunction(data);
    });

myFunction(p) {
// Your Logic //
}

Upvotes: 1

Related Questions