angular - Angular 6 组件类拆分文件
问题描述
如何将一个组件类拆分为多个文件?
想象一下这个组件:
//main.ts
@Component({
selector: "sg-page-main",
templateUrl: "main.html",
})
export class MainPageComponent {
public b : number = 41;
public aff(): void {console.log(this.b)}
public increment(): void {this.b=this.b+1}
}
我想将函数“增量”放入另一个文件中。在我的项目中,组件中有 50 多个函数,它们都使用“this”范围。
解决方案
推荐阅读
- python - 无法在 docker 容器中安装 h2o
- url - 带有 2 个域的域重定向
- vue.js - 标题按钮的Vue全日历本地化
- sql - 逐行计算查询运行总计
- python - 如果替代已在 scs.ttest_ind() 中编码为上 1 尾测试,我是否需要将 p 值除以 2?
- reactjs - 如何在 formik 中使用反应数字格式
- php - 一次登录就禁用多个登录codeigniter
- sql - 比较表中的 2 列值并在新列中显示匹配值。列值以逗号分隔
- javascript - 使用外部 json 数据在 html 输入中创建具有自动完成功能的弹出窗口
- c++ - 有没有办法创建一个由操作系统(Windows、操作系统、Linux)解释为单个文件的文件夹?