0

I have two inputs, one for Landlord Name, and second for Organization Name

Here is code

  <div class="form-group">
                    <label>{{l("Name")}}</label>
                    <input #nameInput class="form-control" type="text" name="name" [(ngModel)]="landlord.name" required maxlength="32">
                </div>
                <div class="form-group">
                    <label>{{l("OrganizationName")}}</label>
                    <input class="form-control" type="email" name="organizationName" [(ngModel)]="landlord.organizationName" required maxlength="500">
                </div>

I need to populate organizationName, when I enter value in Name field. How I can do this?

1
  • You can also use some npm module in order to achieve your requirement. :) Commented Mar 11, 2019 at 9:33

1 Answer 1

1

You can use ngModelChange event emitter, like:

<input #nameInput (ngModelChange)="onNameChange($event)" class="form-control" type="text" name="name" [(ngModel)]="landlord.name" required maxlength="32">

And define onNameChange in your component:

public onNameChange(name: string) {
    // implement some logic for picking the organization name
    // and update the input
    this.landlord.organizationName = 'some organization name';    
}
Sign up to request clarification or add additional context in comments.

1 Comment

yeah. this helps. Thanks so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.