Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to enable view transitions in an Angular 17 app with NgModules?

The Angular 17 blog post says:

You can add this feature to your app today by configuring it in the router’s provider declaration during bootstrap:

bootstrapApplication(App, {
  providers: [
    provideRouter(routes, withViewTransitions()),
  ]
});

However, I’m using NgModules, so my main.ts bootstrap looks like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

platformBrowserDynamic().bootstrapModule(AppModule)

And the RouterModule is imported in the each of the modules, like:

@NgModule({
  imports: [
    RouterModule.forChild(routes),
  ]

So, no providers and no provideRouter() method. Where do I need to add withViewTransitions()?

>Solution :

You you can do it with it forRoot. You need to set this up at the application level.

RouterModule.forRoot([ /* routes...*/], {enableViewTransitions: true}], 

This is defined in ExtraOptions.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading