Call ion-view in function

1

I'm starting in Ionic and AngularJS, I already googlei enough and I did not find anything about this simple doubt.

I can navigate well between ion-view "Page1" and "Page2" using the buttons:

<ion-view view-title="Page1">
  <ion-content>
    <h1>Page 1</h1>
    <a class="button icon icon-right ion-chevron-right" href="#/app/page2">Page 2</a>
  </ion-content>
</ion-view>

<ion-view view-title="Page2">
  <ion-content>
    <h1>Page 2</h1>
    <a class="button icon icon-right ion-chevron-right" href="#/app/page1">Page 1</a>
  </ion-content>
</ion-view>

But I would like to do this through a function:

function EventoTal(){

      carregue("page2");

}

No need to click the button.

In jQuery $(elemento).show();

    
asked by anonymous 15.05.2015 / 17:54

1 answer

0

It will not work with Ionic, but since it is Web-based, we can try the following code equivalent to what <a href="#/app/page2">Page 2</a> does:

location.hash = "/app/page2";

Or so to keep page stack history:

if(history.pushState) {
    history.pushState(null, null, '#/app/page2');
}
else {
    location.hash = '#/app/page2';
}
    
15.05.2015 / 18:54