Index.html file is:
<body>
<mat-spinner></mat-spinner>
</body>
App.module file is:
@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatProgressSpinnerModule,
BrowserAnimationsModule
]
})
I see on the page tag <mat-spinner></mat-spinner>
but it does not work, no any errors in console
Angular components can't be rendered on their own inside the index.html file. That's why default AppComponent is bootstrapped through main.ts file.
You should include the mat-spinner inside an Angular Component. If the spinner is meant to be displayed on application boostraping, you must use a custom spinner which can then be included in the index.html :
To display a spinner when lazy loading a module on routing, you can listen to
router.events
in the component containing the<router-outlet>
:and display conditionally your spinner :
here is a stackblitz example (but the spinner isn't displayed as the modules are loaded too quickly) : https://stackblitz.com/edit/angular-ivy-xwd2ta?file=src%2Fapp%2Fapp.component.ts