Ionic2 angular2 load view after subscribe
<p>I'm looking to go to the next view in my app after running an http post.</p>

<p>I have 3 service:</p>

<ol>
<li><p>server service - generic http calls - get, post etc</p></li>
<li><p>city service - stores a city list data across the app which call service 1 and gets data</p></li>
<li><p>drill service - drills into the city list displays info about the city once its receives the data from city service </p></li>
</ol>

<p>In angular 1 I would pass in a function (callback) that would denote its ok to load the page or do something now we have the data. However I'm a little stuck in version 2 on how to achieve this after a http call.</p>

<p>Server service I use for generic post or get requests: </p>

<pre><code>post(data){       
 var postData = 'data='+JSON.stringify(data);

 return this.http.post(this.server, postData, {
  headers: this.headers
 })
 .map(res =&gt; res.json());          
}
</code></pre>

<p>City service that calls the above <code>post(data)</code> city service also stores the data which, I re-use across the app:</p>

<pre><code>viewCity(send){   
this.server.post(send).subscribe((data) =&gt; {        
    this.data.cityData = data.city;
    //ONCE HERE I WANT TO THEN LOAD THIS
    //ANGULAR ONE THE CALLBACK RUN HERE
});
}
</code></pre>

<p>So when I call <code>viewCity</code> from the <code>drill</code> service how can I get ionic to change view after the call has finished?</p>

<p>I've tried using a callback but the function passed in is null and doesn't work. Incorrect TypeScript syntax maybe?</p>

<p>EDIT / UPDATE:</p>

<p>So i have managed to make it work but i don't like the solution. Can anyone improve on this:</p>

<pre><code>  viewCity(r){    
  this.cityService.getCity(r)
  .subscribe((data) =&gt; {  //call the service and return the http object
      this.cityService.data.city = data.city; //set the data back through to the service
      this.nav.push(RestaurantPage); //load the page and access the service in this component 
  });
  } 
</code></pre>