I'm new in Onsen UI. How should I use the 'go-back'-method to go back to the main page? (Like the left back button.) I've tried to do this with pushPage-Method. It works, but the animation is different.
HTML of the Template with the back / save-Button
<ons-navigator var="profileNavigator">
<ons-list ng-repeat="item in profileData">
<ons-list-item modifier="chevron" class="profile-list-item-container" ng-click="openAboutMeDesc(item.aboutMe)">
<div class="profile-list-item-left">
<i class="fa fa-child fa-profile-list"></i>
</div>
<div class="profile-list-item-right">
<div class="profile-list-item-content">
<div class="profile-category">Über mich
</div>
<span class="profile-desc">{{item.aboutMe}}</span>
</div>
</div>
</ons-list-item>
<ons-template id="profile-aboutme-desc.html">
<ons-page>
<ons-toolbar>
<div class="left">
<ons-back-button>Back</ons-back-button>
</div>
<div class="right">
<ons-toolbar-button ng-click="saveAboutMeDesc(item.naboutMe)">Save</ons-toolbar-button></div>
<div class="center">About</div>
</ons-toolbar>
<ons-row>
<!--my content-->
</ons-row>
</ons-page>
</ons-template>
</ons-navigator>
JavaScript
$scope.openAboutMeDesc = function (aboutMe) {
profileNavigator.pushPage('profile-aboutme-desc.html', { animation : 'slide' } );
};
$scope.saveAboutMeDesc = function (naboutMe) {
};
The animation is different (forward instead of backward) because, using profileNavigator.pushPage
method, you are adding a new page to the stack instead of going back to an old one. If you need to go to the main page, consider using profileNavigator.resetToPage
method.
$scope.openAboutMeDesc = function (aboutMe) {
profileNavigator.resetToPage('profile-aboutme-desc.html', { animation : 'slide' } );
};
Remember that you can select the transaction animation between "slide", "simpleslide", "lift", "fade" and "none".
Take a look at the official documentation if there is something not clear:
https://onsen.io/reference/ons-navigator.html
Hope it helps!