Skip to content

Commit 30ba625

Browse files
committed
refactor(@schematics/angular): use more comprehensive template vars in module gen
1 parent 488bb9b commit 30ba625

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

packages/schematics/angular/module/files/__name@dasherize@if-flat__/__name@dasherize__.module.ts.template

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { NgModule } from '@angular/core';<% if (commonModule) { %>
2-
import { CommonModule } from '@angular/common';<% } %><% if (lazyRoute && routeDeclarationInlined) { %>
2+
import { CommonModule } from '@angular/common';<% } %><% if (lazyRouteWithoutRouteModule) { %>
33
import { Routes, RouterModule } from '@angular/router';<% } %>
4-
<% if (routing || lazyRoute && !routeDeclarationInlined) { %>
4+
<% if (routing || lazyRouteWithRouteModule) { %>
55
import { <%= classify(name) %>RoutingModule } from './<%= dasherize(name) %>-routing.module';<% } %>
6-
<% if (lazyRoute && routeDeclarationInlined) { %>
6+
<% if (lazyRouteWithoutRouteModule) { %>
77
const routes: Routes = [
88
{ path: '', component: <%= classify(name) %>Component }
99
];<% } %>
1010

1111
@NgModule({
1212
declarations: [],
1313
imports: [<% if (commonModule) { %>
14-
CommonModule<%= routing || lazyRoute && !routeDeclarationInlined ? ',' : '' %><% } %><% if (routing || lazyRoute && !routeDeclarationInlined) { %>
15-
<%= classify(name) %>RoutingModule<% } %><%= lazyRoute && routeDeclarationInlined ? ',' : '' %><% if (lazyRoute && routeDeclarationInlined) { %>
14+
CommonModule<%= routing || lazyRouteWithRouteModule ? ',' : '' %><% } %><% if (routing || lazyRouteWithRouteModule) { %>
15+
<%= classify(name) %>RoutingModule<% } %><%= lazyRouteWithoutRouteModule ? ',' : '' %><% if (lazyRouteWithoutRouteModule) { %>
1616
RouterModule.forChild(routes)<% } %>
1717
]
1818
})

packages/schematics/angular/module/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ export default function (options: ModuleOptions): Rule {
158158
...strings,
159159
'if-flat': (s: string) => options.flat ? '' : s,
160160
lazyRoute: isLazyLoadedModuleGen,
161-
routeDeclarationInlined: !routingModulePath,
161+
lazyRouteWithoutRouteModule: isLazyLoadedModuleGen && !routingModulePath,
162+
lazyRouteWithRouteModule: isLazyLoadedModuleGen && routingModulePath,
162163
...options,
163164
}),
164165
move(parsedPath.path),

0 commit comments

Comments
 (0)