<input {{field.validatorDirective}}
class="form-control"
[ngClass]="{ 'border-danger': hasErrors }"
(keyup)="callback()"
[formControlName]="field.key"
[id]="field.key"
[type]="field.type"
[placeholder]="field.placeholder"
[value]="field.value">
field
包含了所需的所有内容,但我希望能动态地添加指令名称。目前它作为
string
添加在field.validatorDirective
中。这会导致错误:
我的指令选择器是TextComponent.html:2 ERROR DOM Exception: Failed to execute 'setAttribute' on 'Element': '{{field.validatorDirective}}' is not a valid attribute name.
usernameValidator
。
usernameValidator
,它将作为field.validatorDirective
传递。 - user9366125