मान लीजिए मैं निम्नलिखित मॉडल संचालित रूप है:अंक
this.addressForm = this.formBuilder.group({
address: this.formBuilder.group({
placeId: [this.address.placeId],
description: [this.address.description]
})
});
और निम्न टेम्पलेट:
<form [formGroup]="addressForm" (ngSubmit)="updateAddress()" novalidate>
<div class="form-group">
<div class="input-group">
<input type="text"
formControlName="address"
placeholder="Type in you address"
[ngbTypeahead]="chooseAddress"
[inputFormatter]="addressFormatter"
[resultFormatter]="addressFormatter"
autocomplete="off"
class="form-control">
</div>
...
</form>
addressFormatter:
addressFormatter = param => param.description;
कहेंदो गुणों वाला एक ऑब्जेक्ट है: placeId
और description
।
यह एक formGroup
(यहाँ address
) एक formControl
के बजाय (यहाँ address.placeId
) और अभी भी से निपटने के लिए पूर्व ऑब्जेक्ट के गुणों में से एक (जैसे address.description
) के साथ प्रपत्र पॉप्युलेट असंभव लगता है।
मैं निम्नलिखित त्रुटि मिलती है:
Error in ./UserAccountAddressComponent class UserAccountAddressComponent - inline template:8:9 caused by: control.registerOnChange is not a function TypeError: control.registerOnChange is not a function
मैं क्षेत्र (address.description
) में वस्तु में से एक संपत्ति प्रदर्शित करने के लिए सक्षम नहीं था और जब मैं प्रपत्र (address.placeId
) जमा एक और एक का उपयोग किया जा रहा है, जबकि अभी भी ऑब्जेक्ट गुणों में से किसी एक के साथ फ़ॉर्म को पूर्ववत करने में सक्षम (यहां address.description
)।
क्या कोई मदद कर सकता है?
टाइपो? '[formControl] =" adressForm.adress "' – stealththeninja
@ करबोस: आपके इनपुट के लिए बहुत बहुत धन्यवाद। क्या आप कृपया बता सकते हैं कि '[formControl]' बाध्यकारी क्या हासिल करने जा रहा है और इसे 'formControlName' विशेषता' से तुलना करें? – balteo
@stealththeninja: मैंने टाइपो देखा और "पता" में बदल गया है। आप को भी धन्यवाद। – balteo