i have this email model:
export class Email{
to: Array<
{
email: string
name: string
}
>
from: {
email: string
name: string
}
cc: Array<
{
email: string
name: string
}
>
bcc: Array<
{
email: string
name: string
}
>
subject: string
body: string
type: string
}
Then I import the email model and declare it in the class like this:
import { Email } from '@/models/email';
export class BuilderJobComponent implements OnInit {
emailJobData: Email
Later on, inside a class method I try to set a value but I get undefined. What am I not understanding about this?
Cannot read property 'from' of undefined
this.emailJobData.from.email = email
this.emailJobData.from.name = name
// set the To address
if( Recipient ){
this.emailJobData.to.push({ email: Recipient, name: '' })
}