So lets say I want a create a custom component in Angular 2+ for the following class
public class user {
name: string;
id: number;
address: string;
}
I've created a custom component
<input [(ngModel)]="name" />
<input [(ngModel)]="id" />
<input [(ngModel)]="address" />
I've added this custom component into my main page
<user-component></user-component>
What I want to do now is pass the User class as ngModel inside my custom component and bind it with public user:User
variable in my main page class. Something like this
<user-component [(ngModel)]="user"></user-component>
I've found few examples of using ControlValueAccessor, NG_VALUE_ACCESSOR
but all these examples work with single component like one text input. Is there a way to make it work for multiple inputs inside the custom component as well?