Skip to content

Commit 8b5abf7

Browse files
committed
fix: with platform-browser, provideZoneChangeDetection belongs in app.module.ts
With Angular 21, provideZoneChangeDetection is required, otherwise our microphone buttons don't work properly, but with the deprecated platform-browser-dynamic, that belonged in main.ts, while with the recommended platform-browser, it has to be moved to the NgModule's provides in app.module.ts.
1 parent 6280a55 commit 8b5abf7

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

packages/angular-demo/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgModule } from "@angular/core";
1+
import { NgModule, provideZoneChangeDetection } from "@angular/core";
22
import { BrowserModule } from "@angular/platform-browser";
33

44
import { AppComponent } from "./app.component";
@@ -10,7 +10,7 @@ defineCustomElements();
1010
@NgModule({
1111
declarations: [AppComponent],
1212
imports: [BrowserModule, NgxRAWebComponentModule],
13-
providers: [],
13+
providers: [provideZoneChangeDetection()],
1414
bootstrap: [AppComponent],
1515
})
1616
export class AppModule {}

packages/angular-demo/src/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { provideZoneChangeDetection } from "@angular/core";
21
import { platformBrowser } from "@angular/platform-browser";
32

43
import { AppModule } from "./app/app.module";
54

65
platformBrowser()
7-
.bootstrapModule(AppModule, {
8-
applicationProviders: [provideZoneChangeDetection()],
9-
})
6+
.bootstrapModule(AppModule)
107
.catch((err) => console.error(err));

packages/studio-web/src/app/app.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { ToastrModule } from "ngx-toastr";
22

33
import { provideHttpClient } from "@angular/common/http";
4-
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from "@angular/core";
4+
import {
5+
CUSTOM_ELEMENTS_SCHEMA,
6+
NgModule,
7+
provideZoneChangeDetection,
8+
} from "@angular/core";
59
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
610
import { BrowserModule } from "@angular/platform-browser";
711
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
@@ -53,7 +57,7 @@ defineCustomElements();
5357
NgxRAWebComponentModule,
5458
SharedModule,
5559
],
56-
providers: [provideHttpClient()],
60+
providers: [provideHttpClient(), provideZoneChangeDetection()],
5761
bootstrap: [AppComponent],
5862
schemas: [CUSTOM_ELEMENTS_SCHEMA],
5963
})

packages/studio-web/src/main.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { enableProdMode, provideZoneChangeDetection } from "@angular/core";
21
import { platformBrowser } from "@angular/platform-browser";
2+
import { enableProdMode } from "@angular/core";
33

44
import { AppModule } from "./app/app.module";
55
import { environment } from "./environments/environment";
@@ -9,7 +9,5 @@ if (environment.production) {
99
}
1010

1111
platformBrowser()
12-
.bootstrapModule(AppModule, {
13-
applicationProviders: [provideZoneChangeDetection()],
14-
})
12+
.bootstrapModule(AppModule)
1513
.catch((err: any) => console.error(err));

0 commit comments

Comments
 (0)