It seems like such a simple thing to do, but for some reason I can't seem to get it right.
Here is what I have in my class:
interface Message {
type: string;
email: string;
}
export class MyClass {
public message: Message;
public email: string;
constructor() { }
// ...
}
When I bind the email variable using [(ngModel)]='email'
, everything works fine. But when I try to bind the message with [(ngModel)]='message.email'
, I encounter this error:
Cannot read property 'email' of undefined.
Why does Angular fail to access my object variable?