Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ngx-Spinner is not working in feature module

Ngx-Spinner it is working fine when i call it in inside the main module i.e. app-module.

I am using line spinner on complete page so i define it inside the app-component.html

<ngx-spinner bdColor="rgba(51, 51, 51, 0.47)" size="medium" color="#fff" type="line-spin-clockwise-fade"></ngx-spinner>

but in case of when i am trying to show this spinner by calling from a component of feature module , it is not working .

like image 875
Sunny Goel Avatar asked Dec 21 '25 09:12

Sunny Goel


2 Answers

You need to move this ngx-spinner into separate component. You can call this spinner component using Subject/BehaviorSubject using next() operator in the source component.

You can listen for the data in the 'ngx-spinner' component using subscribe method for display/hide the spinner.

like image 81
Suresh Kumar Ariya Avatar answered Dec 24 '25 00:12

Suresh Kumar Ariya


When working with feature modules and lazy loading, you also need to import the NgxSpinnerModule into your feature module.

@NgModule({
    imports: [
        CommonModule,
        NgxSpinnerModule,
        ...
    ],
})
export class FeatureModule { ... }

Hope it helps


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!