how to pass data to a form in another component in Angular


I have a form in a seperate component which looks like this:

<form [formGroup]="form">
    <div class="card" style="margin-bottom: 10px" >
    <input 
        formControlName="name" 
        type="text"
        placeholder="please enter"
        />
</div>
</form>

the ts file looks like this (formcontrol part)

 form = this.builder.group({
    name: new FormControl(),
  })

this is how I call it from the other component:
component B:

 <form></form>

What I want to achieve now is the following I am filling some values from my backend which works, I know want to asign these values to my form from the form component. I know I have to use @Input I am kinda stuck against a wall and dont know how to connect them. Can someone give me a small example how I can fill my form from values from component b?

Source: JavaSript – Stack Overflow

November 22, 2021
Category : News
Tags: angular | javascript | typescript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.