Angular4 edit method

0

I started in the angle4 shortly, I need to get the information of a field and go to the edit screen, I already have this information in a console.log of the screen edit that I put to test, only problem is that n to achieve display in the fields, maybe it would be the Input decorator but not able to use it, any help?

I have this condition if in case the ID has defined it search in the regioesById service for route edit, I already have the id in 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 constructor this variable that receives the regions:

Regions: Regions

    
asked by anonymous 14.02.2018 / 12:07

1 answer

0

Basically what you need is to inform the ngModel directive in the field and either 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

20.02.2018 / 08:34