jQWidgets Forums

jQuery UI Widgets Forums Angular ngOnChanges

This topic contains 2 replies, has 3 voices, and was last updated by  alexgilbert 1 year, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    ngOnChanges Posts
  • ngOnChanges #100858

    gregory.michel
    Participant

    Hi,

    I have a component with different input.
    when these inputs change, it must produce a data reload and a chart/grid/… refresh.
    But i can t interact with jqwidget component in angular ngOnChanges cause jqwidget components are not yet created.
    I can’t do these kind of code:

    ngOnChanges(changes: SimpleChanges) {
    this.jqxLoader.open();
    this.dataService.loadData(this.beginTime, this.endTime)
    .subscribe(data=> {
    this.loadChartData(data);
    this.myChart.refresh();
    this.jqxLoader.close();
    }

    ngOnInit() {
    }

    ngAfterViewInit(): void {
    this.myChart.createComponent(this.settings);
    }

    How can i do this?

    ngOnChanges #100872

    Martin
    Participant

    Hello gregory.michel,

    jQWidgets components are created after ngOnChanges is triggered for the first time.
    You can use the SimpleChanges argument that is received by ngOnChange to check if this is the first change of your input.
    For example:

    ngOnChanges(changes: SimpleChanges) {
    
      if (!changes.yourInput.firstChange) {
    
        this.jqxLoader.open();
        this.dataService.loadData(this.beginTime, this.endTime)
        .subscribe(data=> {
        this.loadChartData(data);
        this.myChart.refresh();
        this.jqxLoader.close();
    
      }
    }

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

    ngOnChanges #133203

    alexgilbert
    Participant

    Hey thanks for sharing it with us

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.