Skip to content Skip to sidebar Skip to footer

Plotly In Angular 4 Not Finding Html Element With Ngif

I am building an angular 4 App that needs a graph. For graphs I am using Plotly.js, this works as it should, except if I use ngIf. So what I want to do: I have a div in wich the gr

Solution 1:

import { ChangeDetectorRef } from '@angular/core';

constructor(private cdRef:ChangeDetectorRef){}

switchView(){
    this.graph = !this.graph;
    this.cdRef.detectChanges(); // <<< ensure the bindings are updated
    if(this.graph){
      this.draw();
    } else {
      /*tableview*/
    }
}

Post a Comment for "Plotly In Angular 4 Not Finding Html Element With Ngif"