Angular4 method edit

Asked

Viewed 42 times

0

I started in angular4 a little while, I need to take the information of a field and pass to the screen of Edit, I already have this information in a console.log of the screen Dit that I put to test, only problem is that n being able to display in the fields, maybe it would be the Input developer but I can’t use it, some help?

i have this condition if if the ID has set it search in the service the region to edit route, I already have the id on the route also what is missing is to display, follow code:

 if (this.route.snapshot.params['id'] != undefined) {
      this.regiaoService.regioesById(this.route.snapshot.params['id'])
        .subscribe(
          regioes => {
            this.regioes = regioes
            this.idRegioes = regioes.codigoregiao
            console.log(this.regioes);
        })
    }

I declare before the builder that variable that receives the regions:

regions : Regions

1 answer

0


Basically what you need is to inform the directive ngModel in the field and or ngFor if the variable contains an array.

<input type="text" [ngModel]="regioes">
<input type="text" [ngModel]="idRegioes">

Being an array:

<select>
    <option *ngFor="let regiao of regioes" value="{{regiao.id}}">{{regiao.nome}}</option>
</select>

Reference

  • I had already solved, but you’re right wmsouza, this is how I solved, anyway thank you :))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.