cpa*_*817 5 forms material-design angular-formly angular
我正在尝试评估Formly。这是我的第一次尝试 - 我想在文本区域的值发生变化时调用一个方法。这是我尝试过的代码 - 到目前为止它似乎不起作用我不确定我的 templateOptions 语法是否错误或者我是否应该访问不同的输入值。
form = new FormGroup({});
model = { defaultText: this.defaultText } ;
label = this.defaultText ;
fields: FormlyFieldConfig[] = [{
key: 'editor',
id: 'editor',
name: 'editor',
type: 'textarea',
templateOptions: {
placeholder: this.defaultText,
onChange: this.previewText = this.parseMarkDownText(this.form.get('editor').value),
// appearance: 'fill'
}
}];
Run Code Online (Sandbox Code Playgroud)
哎呀,我忘了发布我的答案。这就是有效的。
ngOnInit() {
this.form = new FormGroup({});
this.fields = [{
key: 'editor',
id: 'editor',
name: 'editor',
type: 'textarea',
defaultValue: this.defaultText,
templateOptions: {
rows: 5,
cos: 50,
change: (field, $event)=>{
this.previewText = this.parseMarkDownText(field.form.controls.editor.value);
},
}
}];
}
```
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8759 次 |
| 最近记录: |