title: Optimal way of accessing parent view property (Ionic 2, Angular 2)
body: <p>I'm testing Ionic 2 and Angular 2, and I've got a doubt about accessing to parent view's properties.</p>
  
  <p>Per example, I've got a test app in which my view is a list of items, and when I click one item, I enter to their details. Pretty straightforward, huh? Well, that details view has got functions that edit the element, and then apply the changes.</p>
  
  <p>For this, I use three different ways:</p>
  
  <ul>
  <li>One is to pass the object reference and just edit it, which edits it back in the list (I guess this is pretty optimal)</li>
  <li>Before the typical navCtrl.pop(), pass a parameter via navParam to the function "ionViewDidEnter()", which executes just when you come back to a view, and filter it there, so you can perform the task you desire. Problem: it doesn't work (probably it's a bug).</li>
  <li>Here comes the krakken: when <strong>removing</strong> the element, this won't work, since I have <strong>to remove it from the list</strong>, per example, with the typical list.splice(index, 1);</li>
  </ul>
  
  <p>I found two different methods of performing this: you can either pass the new view a reference of the list, or you can access it from the NavController, just as I do here:</p>
  
  <pre><code>  remove(){
      let list = this.navCtrl._views[0].instance.list;
  
      for(var i=0;i&lt;list.length;i++){
          if(list[i].id === this.contact.id){
              list.splice(i,1);
          }
      }
      this.navCtrl.pop();
    }
  </code></pre>
  
  <p>Here I have another example of this weird technique, reusing the edit view for creating a new element:</p>
  
  <pre><code>  editContact(obj){
      if(this.onEdit){
          this.onEdit = false;
          this.editBtnTxt = "Edit contact";
          if(this.onCreate){
              this.navCtrl._views[0].instance.list.push(this.contact);
              this.navCtrl.pop();
          }
      }else{
          this.editBtnTxt = 'Apply changes';
          this.onEdit = true;
  
      }
    }
  </code></pre>
  
  <p>Although this works pretty nicely and isn't throwing any errors, I guess I'm just being somewhat lucky, because: how do you know the index of the view you want to access, if you're not in a simple test project like this with two views, per example? I guess there can be a lot of errors with this way of doing things.</p>
  
  <p>But as it works, and it seems to be more optimal than passing tons of parameters, or using localStorage as a "global" variable, I'm sticking with this by the moment. </p>
  
  <p>What I would like to know, is... <strong>which way is the most optimal of accessing parent view properties?</strong> </p>