【发布时间】:2018-02-23 22:11:03
【问题描述】:
我需要在 Angular 中呈现控件的属性。属性将基于属性进行配置。用户将发送一个 JSON 文件,该文件将被序列化为 typescript 中的一个对象。此打字稿文件将用作组件上的绑定。
{
"row": 1,
"col": 2,
"key": "Input_2",
"label": "First Name",
"required": true,
"type": 1,
"hiddden": false,
"maxLength": 100,
"attributes": "required validateEqual='password' reverse='false'"
}
export class ControlBase<T> {
row: number;
col: number;
value?: string;
key: string;
label: string;
required: boolean;
type: ControlType;
hidden: boolean = false;
attributes: string;
}
<input class="form-control" type="text" [(ngModel)]="value" {{control.attributes}}>
当我使用上述绑定 {{control.attributes}} 时,我收到以下错误:无法在“元素”上执行“setAttribute”:“{{control.attributes}}”不是有效的属性名称。
【问题讨论】:
标签: angular