I have a file that I'm using to create an object to store in my Firestore database. The file is imported into my register page, and I'm using ngModels to capture user-input values. To achieve this, I've initialized my data object inside the register page and created a variable named "Usuario" to hold the object from my file.
Below is the structure of my object:
export const data = {
Document: {
cpf: "",
sus: "",
birth_date: "",
email: "",
confirm_email: "",
phone: "",
password: "",
confirm_password: ""
}
};
Next, I import the file:
import * as myData from '../interface/patient.interface';
And then I instantiate myData class like so:
export class RegistrationPage {
Usuario = myData;
}
Afterwards, I retrieve and store the HTML input values like this:
<ion-list>
<ion-item>
<ion-label floating>CPF</ion-label>
<ion-input type="number" [(ngModel)]="Usuario.Document.cpf"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>SUS Card - CNS</ion-label>
<ion-input type="number" [(ngModel)]="Usuario.Document.sus"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Date of Birth</ion-label>
<ion-input type="text" [(ngModel)]="Usuario.Document.birth_date"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Email</ion-label>
<ion-input type="email" [(ngModel)]="Usuario.Document.email"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Confirm Email</ion-label>
<ion-input type="email" [(ngModel)]="Usuario.Document.confirm_email"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Mobile Phone with area code</ion-label>
<ion-input type="tel" [(ngModel)]="Usuario.Document.phone"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input type="password" [(ngModel)]="Usuario.Document.password"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Confirm Password</ion-label>
<ion-input type="password" [(ngModel)]="Usuario.Document.confirm_password"></ion-input>
</ion-item>
However, when I attempt to click the register button, I encounter the following error:
ERROR TypeError: Cannot read property 'cpf' of undefined