@@ -120,25 +120,50 @@ function getModuleName(addRoute: boolean, moduleName: string) {
120120 return moduleName ;
121121}
122122
123- function addContentToView ( options : any ) {
123+ function overwriteModuleContent ( options : any , path : string , content : string ) {
124124 return async ( host : Tree ) => {
125- const name = strings . dasherize ( basename ( normalize ( options . name ) ) ) ;
126- const path = `${ dirname ( options . name ) } /${ name } ` ;
127- const title = humanize ( name ) ;
128- const componentPath = `/${ await getApplicationPath ( host , options . project ) } ${ path } /${ name } .component.html` ;
125+ const componentPath = `/${ await getApplicationPath ( host , options . project ) } ${ path } ` ;
129126 if ( host . exists ( componentPath ) ) {
130- host . overwrite (
131- componentPath ,
132- `<h2>${ title } </h2>
133- <div class="content-block">
134- <div class="dx-card responsive-paddings">Put your content here</div>
135- </div>
136- ` ) ;
127+ host . overwrite ( componentPath , content ) ;
137128 }
138129 return host ;
139130 } ;
140131}
141132
133+ function addContentToView ( options : any ) {
134+ const name = strings . dasherize ( basename ( normalize ( options . name ) ) ) ;
135+ const path = `${ dirname ( options . name ) } /${ name } ` ;
136+ const title = humanize ( name ) ;
137+ const componentPath = `${ path } /${ name } .component.html` ;
138+ const content = `<h2>${ title } </h2>
139+ <div class="content-block">
140+ <div class="dx-card responsive-paddings">Put your content here</div>
141+ </div>
142+ ` ;
143+
144+ return overwriteModuleContent ( options , componentPath , content ) ;
145+ }
146+
147+ async function addContentToTS ( options : any ) {
148+ const name = strings . dasherize ( basename ( normalize ( options . name ) ) ) ;
149+ const path = `${ dirname ( options . name ) } /${ name } ` ;
150+ const componentPath = `${ path } /${ name } .component.ts` ;
151+ const content = `import { Component } from '@angular/core';
152+
153+ @Component({
154+ selector: 'app-new-page',
155+ templateUrl: './new-page.component.html',
156+ styleUrl: './new-page.component.css',
157+ standalone: false
158+ })
159+ export class NewPageComponent {
160+
161+ }
162+ ` ;
163+
164+ return overwriteModuleContent ( options , componentPath , content ) ;
165+ }
166+
142167export default function ( options : any ) : Rule {
143168 return async ( host : Tree ) => {
144169 const addRoute = options . addRoute ;
@@ -155,7 +180,8 @@ export default function(options: any): Rule {
155180 prefix : options . prefix ,
156181 standalone : false
157182 } ) ,
158- addContentToView ( { name, project } ) as any
183+ addContentToView ( { name, project } ) as any ,
184+ addContentToTS ( { name, project } ) as any
159185 ] ;
160186
161187 if ( addRoute ) {
0 commit comments