How to read an array string in Ionic / AngularJs or Javascript and pass to directives?

0

I passed parameters to another TS with:

console.log('Data', navParams.get('sessoes'));

That shows me this result:

{data: "2018-09-11", weight: "200", sessoes: "20", repeticoes: "2", notas: "teste"}

In this way, I can get each of the Array fields:

var object = navParams.get('sessoes');    
      console.log(object["data"]);
      console.log(object["weight"]);
      console.log(object["sessoes"]);
      console.log(object["repeticoes"]);
      console.log(object["notas"]);

Now I need to get this data to be shown on a form that has [(ngModel)]="sessao.data", [(ngModel)]="sessao.weight", [(ngModel)]="sessao.sessoes" , etc ...

How do I put these objects in a ngModel directive for my Ionic / Angular form?

    
asked by anonymous 07.09.2018 / 18:55

1 answer

0

Create an object within the class called session or create and extend an interface

Then pass this created object into your method to receive the array data

 sessao = {data: '', weight: '', sessoes: '', repeticoes: 'repeticoes', notas: ''}

      constructor() {
        let object = navParams.get('sessoes');    
        this.sessao.data = object["data"];
        this.sessao.weight = object["weight"];
        this.sessao.sessoes = object["sessoes"];
        this.sessao.repeticoes = object["repeticoes"];
        this.sessao.notas = object["notas"];
  }
    
11.09.2018 / 15:59