Struggling with creating a form in Angular 2 to submit dynamically generated values from a service. The goal is to calculate the equivalent amount of bitcoin for X chilean pesos using Angular's http module to fetch the price. However, facing an issue where disabled or readonly inputs are not being submitted by angular forms – specifically the exchange rate and target amount (in btc).
Attempted both template-driven and data-driven approaches without success. Values are not logged to console unless disabled/readonly properties are removed from inputs.
Appreciate any assistance on this. Below is the code snippet:
component.ts
// Component logic here
// Code commented out for brevity
In the code provided, note that the data-driven approach is used only in the form submission function.
html:
<form (ngSubmit)="onSub(f)" #f="ngForm">
<div class="form-group">
// HTML input fields here
</div>
<button md-raised-button type="submit" color="primary" class="btn-w-md">Confirm</button><div class="divider divider-sm"></div>
</form>
Thanks again!
EDIT!!!:
data driven html:
<form [formGroup]="myForm2" (ngSubmit)="onSub()">
<div class="form-group">
// Data-driven form fields here
</div>
<button md-raised-button type="submit" color="primary" class="btn-w-md">Confirm</button><div class="divider divider-sm"></div>
</form>