node.js - 如何将节点导入语句添加到具有角度示意图的文件中?
问题描述
我想要一个自定义原理图,它将在我的应用程序中创建一个页面。为此,我想使用现有的核心原理图创建一个路由模块,然后在该模块中创建一个组件来显示我的页面内容,最后将所有内容连接在一起。让我难过的是“将所有东西连接在一起”。我找不到关于“正确”方法的明确指导。我是不是该:
a) 直接修改“模块”和“组件”原理图创建的现有文件?(我不知道该怎么做)
b)使用模板以某种方式将修改合并到文件中?(我也不知道该怎么做)
以下是到目前为止我的页面示意图的 index.ts 文件。我不知道该怎么做,最后由“TODO”评论。
请帮忙!
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;
},
]);
}
解决方案
推荐阅读
- android - Android SQLite 错误:java.lang.IllegalStateException:无法从 CursorWindow 读取第 0 行第 0 列
- java - 使用 Comparator 对 VO 的嵌套列表进行排序
- mysql - 仅返回 COLUMN 中的 UNIQUE 值
- php - 如何在 foreach 中对标题的 $item 值进行排序
- java - 如何获取运行 pgrep 命令的同一进程的进程 ID?
- python - 如何创建具有等效频率表的数据框
- c# - 在执行了许多查询后执行查询超时
- msbuild - MSBuild 在调试配置中工作,但在 azure devops 中发布失败
- c++ - 如何在 C++ 中将 Torch 模型定义为函数的输入
- javascript - 如何在javascript中记住数组值?