【发布时间】:2016-09-19 12:09:56
【问题描述】:
比方说,我想向 NgForm(类)添加方法
NgForm.prototype.markAsDirty = function (): void {
let f: NgForm = this;
Util.forEach(f.form.controls, (k, v: AbstractControl) => {
v.markAsDirty(false);
});
};
这在打字稿中是否可能?
我知道:
- TypeScript add static helper to prototype of existing class
- Extending functionality in TypeScript
- Extending Object.prototype with TypeScript
但它仅适用于接口,不适用于类。
【问题讨论】:
标签: typescript angular prototype