将 ngPaste 与 Angular Formly 结合使用
Using ngPaste with Angular Formly
我正在使用 Angular Formly 来构建一个简单的表单。
我需要在其中一个输入字段中禁用粘贴。早些时候,我禁用了 ng-Paste 默认事件,如此处的答案所述:
但是,由于表单生成现在由 Formly 完成,我如何有条件地将带有函数 ($event.preventDefault) 的指令添加到 Formly 生成的字段中?
我能想到的一个选择是创建一个新模板,但这看起来不像是 DRY 代码。还有另一种方法吗?
扩展现有模板对我来说看起来很枯燥:
formlyConfig.setType({
name: 'nopaste-input',
extends: 'input', // Extend regular input
link: function(scope, el, attrs) {}, // Add functionality here
// etc...
});
自定义模板文档:http://docs.angular-formly.com/docs/custom-templates#creating-a-custom-template
Bootstrap 类型:https://github.com/formly-js/angular-formly-templates-bootstrap/tree/master/src/types
我正在使用 Angular Formly 来构建一个简单的表单。
我需要在其中一个输入字段中禁用粘贴。早些时候,我禁用了 ng-Paste 默认事件,如此处的答案所述:
但是,由于表单生成现在由 Formly 完成,我如何有条件地将带有函数 ($event.preventDefault) 的指令添加到 Formly 生成的字段中?
我能想到的一个选择是创建一个新模板,但这看起来不像是 DRY 代码。还有另一种方法吗?
扩展现有模板对我来说看起来很枯燥:
formlyConfig.setType({
name: 'nopaste-input',
extends: 'input', // Extend regular input
link: function(scope, el, attrs) {}, // Add functionality here
// etc...
});
自定义模板文档:http://docs.angular-formly.com/docs/custom-templates#creating-a-custom-template
Bootstrap 类型:https://github.com/formly-js/angular-formly-templates-bootstrap/tree/master/src/types