title: Edit Items in a List Using Modal in Ionic 3
body: <p>I have created an Array and I'm adding items to the array using Modal.
  Now i need to edit the item by selecting it from the list.
  please help me with the Code.
  How to fetch the item to modal and bring back the edited item in the same place in the list</p>
  
  <p>HOME.HTML</p>
  
  <pre><code>    &lt;ion-header&gt;
    &lt;ion-navbar&gt;
      &lt;ion-title&gt;
        Ionic Blank
      &lt;/ion-title&gt;
    &lt;/ion-navbar&gt;
  &lt;/ion-header&gt;
  &lt;ion-content&gt;
    &lt;ion-list&gt;
      &lt;ion-item *ngFor="let grocery of itemsArray"&gt;{{grocery}}&lt;/ion-item&gt;
    &lt;/ion-list&gt;
    &lt;button ion-button round (click)="addItem()"&gt;Add Item&lt;/button&gt;
  &lt;/ion-content&gt;
  </code></pre>
  
  <p>HOME.TS</p>
  
  <pre><code>    export class HomePage {
  
    public itemsArray = [];
    newItem: any;
    constructor(public navCtrl: NavController, public modalCtrl: ModalController, public navParams: NavParams) {
    }
    ionViewDidLoad() {
      this.newItem = this.navParams.get('data');
      this.itemsArray = [
  
      ];
  
    }
    public addItem() {
      let modalPage = this.modalCtrl.create(ModalPage);
      modalPage.onDidDismiss(data =&gt; {
        this.itemsArray.push(data.name
  );
      });
      modalPage.present();
    } 
  
  
  
  }
  </code></pre>
  
  <p>MODAL.HTML</p>
  
  <pre><code>    &lt;ion-header&gt;
    &lt;ion-navbar&gt;
      &lt;ion-title&gt;Add Item&lt;/ion-title&gt;
      &lt;ion-buttons end&gt;
        &lt;button ion-button (click)="closeModal()"&gt;Close&lt;/button&gt;
      &lt;/ion-buttons&gt;
    &lt;/ion-navbar&gt;
  &lt;/ion-header&gt;
  
  &lt;ion-content padding&gt;
    &lt;ion-list&gt;
      &lt;ion-item&gt;
        &lt;ion-label&gt;Item&lt;/ion-label&gt;
        &lt;ion-input type="text" [(ngModel)]="newItem"&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
      &lt;button ion-button color="secondary" (click)="add()"&gt;Add Item&lt;/button&gt;
    &lt;/ion-list&gt;
  &lt;/ion-content&gt;
  </code></pre>
  
  <p>MODAL.TS</p>
  
  <pre><code>    export class ModalPage {
    name:any;
    newItem: any;
  
    constructor(public navCtrl: NavController, public viewCtrl: ViewController, public navParams: NavParams) {
  
    }
  
  
    ionViewDidLoad() {
      console.log('ionViewDidLoad ModalPage');
    }
    public closeModal() {
      this.viewCtrl.dismiss();
  
    }
    //add() {
    //  let data = {"name": this.newItem};
    //  this.viewCtrl.dismiss(data.name)
   // }
   add() {
    let data = {"name": this.newItem};
    this.viewCtrl.dismiss(data)
  }
  
  }
  </code></pre>
  
  <p>The code untill now works fine.</p>