Answer the question
In order to leave comments, you need to log in
How to pass formControlName to component?
Good afternoon.
There is a small input component
@Component({
selector: 'input',
templateUrl: './input.component.html',
styleUrls: ['./input.component.scss']
})
export class InputComponent implements OnInit {
@Input() label: string;
constructor() { }
ngOnInit() {
}
}
<div class="group">
<input type="text" required>
<span class="bar"></span>
<label>{{label}}</label>
</div>
initForm() {
this.SignupReactiveForm = this.fb.group({
password: ['', [
Validators.required,
Validators.pattern(/[A-z]/)
]
],
email: ['', [
Validators.required, Validators.email
]
],
});
}
formControlName="password"
<med-input [label]="'Email'"></med-input>
<div class="group">
<input type="text" required formControlName="password">
<span class="bar"></span>
<label>{{email}}</label>
</div>
Answer the question
In order to leave comments, you need to log in
There are several ways
1) Pass FormControl
2) Implement ControlValueAccessor
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question