Can someone help me figure out how to use the patchValue
method in the ngOnInit() function? I'm trying to populate a HTML select dropdown with a value from a link, but it's not working as expected.
Note: onTest() works perfectly when called separately.
@ViewChild('FomrElm', {static: false}) RentForm: NgForm;
ngOnInit() {
if (this.route.snapshot.params['brand'] != null) {
console.log('::' + this.route.snapshot.params['brand']);
this.RentForm.form.patchValue({
Brand: 'Peugeot'
});
this.brand_V = this.route.snapshot.params['brand'];
this.model_V = this.route.snapshot.params['model'];
}
onTest(){
this.RentForm.form.patchValue({
Brand: 'Peugeot'
});
}
}