Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- externalSchematic,
- Rule,
- SchematicContext,
- Tree,
- chain,
- } from '@angular-devkit/schematics';
- export function page(options: any): Rule {
- const name = options.name;
- return chain([
- // create module for this page
- externalSchematic('@schematics/angular', 'module', {
- name: `pages/${name}`,
- routing: true
- }),
- // create simple component to display in this page
- externalSchematic('@schematics/angular', 'component', {
- name: `pages/${name}/${name}`,
- routing: true
- }),
- // add component to routing module
- (tree: Tree, _context: SchematicContext) => {
- // TODO 1: import new component into routing module
- // e.g. import { MyPageComponent } from "./my-page/my-page.component";
- // TODO 2: add component to routes
- // const routes: Routes = [{ path: '', pathMatch: 'full', component: MyPageComponent }];
- return tree;
- },
- ]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement