Nebular: Error nbSpinner Keep loading !!!

Created on 10 Oct 2018  路  1Comment  路  Source: akveo/nebular

Issue description

Hi everyone,
I use nbSpinner in parent-component:

.................

..................
(notify)="onChartNotify($event)">

In child-component.ts notify EventEmitter will return a boolean value:
...............
@Output()
notify: EventEmitter = new EventEmitter();
.............................
private generateToolBox() {
return {
orient: 'vertical',
top: '5%',
feature: {
myTool1: {
show: true,
title: this.currentTranslations.Report,
icon: ChartConstants.PortraitIcon,
onclick: function () {
this.api.getDom().value.generateReport(false);
}
}
}
}
};
}

generateReport(isExtend: boolean): void {
    this.notify.emit(true);
    setTimeout(() => this.notify.emit(false), 3000);
}

In parent-component.ts, I handle event and set boolean value from child-component to isLoading:
.................
isLoading: boolean;
...................................
onChartNotify(message: boolean): void {
this.isLoading = message;
console.log(this.isLoading);
}

But when notify emit(false) that mean isLoading in parent-component assigned by false, nbSpinner still keep loading on parent page unless I click on the parent page
Please help me fix this problem !

Angular, Nebular

<!--
Check your `package-lock.json` or locate a `package.json` in the `node_modules` folder.
-->

Most helpful comment

this problem is the View will not update after variable change. I fixed:

  • invoking change detection manually:
    import {ChangeDetectorRef} from '@angular/core'
    constructor(private ref: ChangeDetectorRef){}
    ................
    onChartNotify(message: boolean): void {
    this.isLoading = message;
    this.ref.detectChanges();
    }

>All comments

this problem is the View will not update after variable change. I fixed:

  • invoking change detection manually:
    import {ChangeDetectorRef} from '@angular/core'
    constructor(private ref: ChangeDetectorRef){}
    ................
    onChartNotify(message: boolean): void {
    this.isLoading = message;
    this.ref.detectChanges();
    }
Was this page helpful?
0 / 5 - 0 ratings