Questions tagged «form-control»

22
错误错误:表单控件的无值访问器在开关上具有未指定的名称属性
这是我在Angular 4中的组件: @Component( { selector: 'input-extra-field', template: ` <div class="form-group" [formGroup]="formGroup" > <switch [attr.title]="field.etiquette" [attr.value]="field.valeur" [(ngModel)]="field.valeur" [formControl]="fieldControl" [attr.id]="name" [attr.disabled]="disabled"> </switch> <error-messages [control]="name"></error-messages> </div> ` } ) 这是我的课: export class SwitchExtraField extends ExtraField { @Input() field: ExtraFormField; @Input() entity: { fields: Object }; @Input() formGroup: FormGroup; constructor( formDir: NgForm ) { …

5
formControlName和FormControl有什么区别?
我正在使用ReactiveFormsModuleAngular2创建包含表单的组件。这是我的代码: foo.component.ts: constructor(fb: FormBuilder) { this.myForm = fb.group({ 'fullname': ['', Validators.required], 'gender': [] }); } foo.component.html(带有[formControl]): <div class="fields"> <div class="field"> <label>Fullname*</label> <input type="text" [formControl]="myForm.controls.fullname"/> </div> </div> <div class="inline fields"> <label for="gender">Gender</label> <div class="field"> <div class="ui radio checkbox"> <input type="radio" name="gender" checked="" tabindex="0" class="hidden" [formControl]="myForm.controls.gender"> <label>Male</label> </div> </div> <div class="field"> <div …


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.