diff --git a/docs/en/UI/Angular/Migration-Guide-v3.md b/docs/en/UI/Angular/Migration-Guide-v3.md index 987632571a4..6c565360658 100644 --- a/docs/en/UI/Angular/Migration-Guide-v3.md +++ b/docs/en/UI/Angular/Migration-Guide-v3.md @@ -145,42 +145,33 @@ export class AppModule {} AppRoutingModule: ```js -import { DynamicLayoutComponent } from '@abp/ng.core'; import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; const routes: Routes = [ { path: '', - component: DynamicLayoutComponent, - children: [ - { - path: '', - pathMatch: 'full', - loadChildren: () => import('./home/home.module') - .then(m => m.HomeModule), - }, - { - path: 'account', - loadChildren: () => import('@abp/ng.account') - .then(m => m.AccountModule.forLazy({ redirectUrl: '/' })), - }, - { - path: 'identity', - loadChildren: () => import('@abp/ng.identity') - .then(m => m.IdentityModule.forLazy()), - }, - { - path: 'tenant-management', - loadChildren: () => import('@abp/ng.tenant-management') - .then(m => m.TenantManagementModule.forLazy()), - }, - { - path: 'setting-management', - loadChildren: () => import('@abp/ng.setting-management') - .then(m => m.SettingManagementModule.forLazy()), - }, - ], + pathMatch: 'full', + loadChildren: () => import('./home/home.module').then(m => m.HomeModule), + }, + { + path: 'account', + loadChildren: () => + import('@abp/ng.account').then(m => m.AccountModule.forLazy({ redirectUrl: '/' })), + }, + { + path: 'identity', + loadChildren: () => import('@abp/ng.identity').then(m => m.IdentityModule.forLazy()), + }, + { + path: 'tenant-management', + loadChildren: () => + import('@abp/ng.tenant-management').then(m => m.TenantManagementModule.forLazy()), + }, + { + path: 'setting-management', + loadChildren: () => + import('@abp/ng.setting-management').then(m => m.SettingManagementModule.forLazy()), }, ]; @@ -191,7 +182,23 @@ const routes: Routes = [ export class AppRoutingModule {} ``` -> You may have noticed that we used `DynamicLayoutComponent` at top level route component. We made this change in order to avoid unnecessary renders and flickering. It is not mandatory, but we recommend doing the same in your app routing. +AppComponent: + +```js +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + template: ` + + + `, +}) +export class AppComponent {} +``` + + +> You may have noticed that we used `` instead of `` in the AppComponent template. We made this change in order to avoid unnecessary renders and flickering. It is not mandatory, but we recommend doing the same in your AppComponent. #### What to Do When Migrating? @@ -201,7 +208,7 @@ export class AppRoutingModule {} - Call static `forRoot` method of `ThemeBasicModule` (or `ThemeLeptonModule` if commercial) and remove `SharedModule` from imports (unless you have added anything that is necessary for your root module in it). - Import lazy ABP modules directly in app routing module (e.g. `() => import('@abp/ng.identity').then(...)`). - Call static `forLazy` method of all lazy modules inside `then`, even if a configuration is not passed. -- [OPTIONAL] Add an empty parent route with `DynamicLayoutComponent` for better performance and UX. +- [OPTIONAL] Add the `` to the AppComponent template and remove the `` for better performance and UX. ### RoutesService diff --git a/npm/ng-packs/apps/dev-app/src/app/app-routing.module.ts b/npm/ng-packs/apps/dev-app/src/app/app-routing.module.ts index 8f6973079dd..5bfedf645b8 100644 --- a/npm/ng-packs/apps/dev-app/src/app/app-routing.module.ts +++ b/npm/ng-packs/apps/dev-app/src/app/app-routing.module.ts @@ -1,37 +1,30 @@ -import { ABP, DynamicLayoutComponent } from '@abp/ng.core'; import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; const routes: Routes = [ { path: '', - component: DynamicLayoutComponent, - children: [ - { - path: '', - pathMatch: 'full', - loadChildren: () => import('./home/home.module').then(m => m.HomeModule), - }, - { - path: 'account', - loadChildren: () => - import('@abp/ng.account').then(m => m.AccountModule.forLazy({ redirectUrl: '/' })), - }, - { - path: 'identity', - loadChildren: () => import('@abp/ng.identity').then(m => m.IdentityModule.forLazy()), - }, - { - path: 'tenant-management', - loadChildren: () => - import('@abp/ng.tenant-management').then(m => m.TenantManagementModule.forLazy()), - }, - { - path: 'setting-management', - loadChildren: () => - import('@abp/ng.setting-management').then(m => m.SettingManagementModule.forLazy()), - }, - ], + pathMatch: 'full', + loadChildren: () => import('./home/home.module').then(m => m.HomeModule), + }, + { + path: 'account', + loadChildren: () => + import('@abp/ng.account').then(m => m.AccountModule.forLazy({ redirectUrl: '/' })), + }, + { + path: 'identity', + loadChildren: () => import('@abp/ng.identity').then(m => m.IdentityModule.forLazy()), + }, + { + path: 'tenant-management', + loadChildren: () => + import('@abp/ng.tenant-management').then(m => m.TenantManagementModule.forLazy()), + }, + { + path: 'setting-management', + loadChildren: () => + import('@abp/ng.setting-management').then(m => m.SettingManagementModule.forLazy()), }, ]; diff --git a/npm/ng-packs/apps/dev-app/src/app/app.component.ts b/npm/ng-packs/apps/dev-app/src/app/app.component.ts index bf2a27962a2..a26e745334d 100644 --- a/npm/ng-packs/apps/dev-app/src/app/app.component.ts +++ b/npm/ng-packs/apps/dev-app/src/app/app.component.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; selector: 'app-root', template: ` - + `, }) export class AppComponent {} diff --git a/templates/app/angular/src/app/app-routing.module.ts b/templates/app/angular/src/app/app-routing.module.ts index 793703a3ade..7e731d1f47c 100644 --- a/templates/app/angular/src/app/app-routing.module.ts +++ b/templates/app/angular/src/app/app-routing.module.ts @@ -1,37 +1,30 @@ -import { ABP, DynamicLayoutComponent } from '@abp/ng.core'; import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; const routes: Routes = [ { path: '', - component: DynamicLayoutComponent, - children: [ - { - path: '', - pathMatch: 'full', - loadChildren: () => import('./home/home.module').then((m) => m.HomeModule), - }, - { - path: 'account', - loadChildren: () => - import('@abp/ng.account').then((m) => m.AccountModule.forLazy({ redirectUrl: '/' })), - }, - { - path: 'identity', - loadChildren: () => import('@abp/ng.identity').then((m) => m.IdentityModule.forLazy()), - }, - { - path: 'tenant-management', - loadChildren: () => - import('@abp/ng.tenant-management').then((m) => m.TenantManagementModule.forLazy()), - }, - { - path: 'setting-management', - loadChildren: () => - import('@abp/ng.setting-management').then((m) => m.SettingManagementModule.forLazy()), - }, - ], + pathMatch: 'full', + loadChildren: () => import('./home/home.module').then((m) => m.HomeModule), + }, + { + path: 'account', + loadChildren: () => + import('@abp/ng.account').then((m) => m.AccountModule.forLazy({ redirectUrl: '/' })), + }, + { + path: 'identity', + loadChildren: () => import('@abp/ng.identity').then((m) => m.IdentityModule.forLazy()), + }, + { + path: 'tenant-management', + loadChildren: () => + import('@abp/ng.tenant-management').then((m) => m.TenantManagementModule.forLazy()), + }, + { + path: 'setting-management', + loadChildren: () => + import('@abp/ng.setting-management').then((m) => m.SettingManagementModule.forLazy()), }, ]; diff --git a/templates/app/angular/src/app/app.component.ts b/templates/app/angular/src/app/app.component.ts index bf2a27962a2..a26e745334d 100644 --- a/templates/app/angular/src/app/app.component.ts +++ b/templates/app/angular/src/app/app.component.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; selector: 'app-root', template: ` - + `, }) export class AppComponent {} diff --git a/templates/module/angular/projects/dev-app/src/app/app-routing.module.ts b/templates/module/angular/projects/dev-app/src/app/app-routing.module.ts index 47b7ce8ecdf..759fad9ebc4 100644 --- a/templates/module/angular/projects/dev-app/src/app/app-routing.module.ts +++ b/templates/module/angular/projects/dev-app/src/app/app-routing.module.ts @@ -1,52 +1,44 @@ -import { ABP, DynamicLayoutComponent } from '@abp/ng.core'; import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; const routes: Routes = [ { path: '', - component: DynamicLayoutComponent, - children: [ - { - path: '', - pathMatch: 'full', - loadChildren: () => - import('./home/home.module').then((m) => m.HomeModule), - }, - { - path: 'account', - loadChildren: () => - import('@abp/ng.account').then((m) => - m.AccountModule.forLazy({ redirectUrl: '/' }) - ), - }, - { - path: 'identity', - loadChildren: () => - import('@abp/ng.identity').then((m) => m.IdentityModule.forLazy()), - }, - { - path: 'tenant-management', - loadChildren: () => - import('@abp/ng.tenant-management').then((m) => - m.TenantManagementModule.forLazy() - ), - }, - { - path: 'setting-management', - loadChildren: () => - import('@abp/ng.setting-management').then((m) => - m.SettingManagementModule.forLazy() - ), - }, - { - path: 'my-project-name', - loadChildren: () => - import('@my-company-name/my-project-name').then((m) => - m.MyProjectNameModule.forLazy() - ), - }, - ], + pathMatch: 'full', + loadChildren: () => import('./home/home.module').then((m) => m.HomeModule), + }, + { + path: 'account', + loadChildren: () => + import('@abp/ng.account').then((m) => + m.AccountModule.forLazy({ redirectUrl: '/' }) + ), + }, + { + path: 'identity', + loadChildren: () => + import('@abp/ng.identity').then((m) => m.IdentityModule.forLazy()), + }, + { + path: 'tenant-management', + loadChildren: () => + import('@abp/ng.tenant-management').then((m) => + m.TenantManagementModule.forLazy() + ), + }, + { + path: 'setting-management', + loadChildren: () => + import('@abp/ng.setting-management').then((m) => + m.SettingManagementModule.forLazy() + ), + }, + { + path: 'my-project-name', + loadChildren: () => + import('@my-company-name/my-project-name').then((m) => + m.MyProjectNameModule.forLazy() + ), }, ]; diff --git a/templates/module/angular/projects/dev-app/src/app/app.component.ts b/templates/module/angular/projects/dev-app/src/app/app.component.ts index bf2a27962a2..a26e745334d 100644 --- a/templates/module/angular/projects/dev-app/src/app/app.component.ts +++ b/templates/module/angular/projects/dev-app/src/app/app.component.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; selector: 'app-root', template: ` - + `, }) export class AppComponent {} diff --git a/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts b/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts index e698be19733..75934a9b704 100644 --- a/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts +++ b/templates/module/angular/projects/my-project-name/src/lib/my-project-name-routing.module.ts @@ -7,7 +7,13 @@ const routes: Routes = [ { path: '', pathMatch: 'full', - component: MyProjectNameComponent, + component: DynamicLayoutComponent, + children: [ + { + path: '', + component: MyProjectNameComponent, + }, + ], }, ];