Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import {
  2. externalSchematic,
  3. Rule,
  4. SchematicContext,
  5. Tree,
  6. chain,
  7. } from '@angular-devkit/schematics';
  8.  
  9. export function page(options: any): Rule {
  10. const name = options.name;
  11.  
  12. return chain([
  13. // create module for this page
  14. externalSchematic('@schematics/angular', 'module', {
  15. name: `pages/${name}`,
  16. routing: true
  17. }),
  18.  
  19. // create simple component to display in this page
  20. externalSchematic('@schematics/angular', 'component', {
  21. name: `pages/${name}/${name}`,
  22. routing: true
  23. }),
  24.  
  25. // add component to routing module
  26. (tree: Tree, _context: SchematicContext) => {
  27. // TODO 1: import new component into routing module
  28. // e.g. import { MyPageComponent } from "./my-page/my-page.component";
  29.  
  30. // TODO 2: add component to routes
  31. // const routes: Routes = [{ path: '', pathMatch: 'full', component: MyPageComponent }];
  32. return tree;
  33. },
  34. ]);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement