1

Onsen UI 初心者です。「戻る」方法を使用してメイン ページに戻るにはどうすればよいですか? (左の戻るボタンのように。) pushPage-Method でこれを実行しようとしました。動作しますが、アニメーションは異なります。

戻る/保存ボタンを含むテンプレートの HTML

<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) {

};
4

1 に答える 1

2

profileNavigator.pushPageメソッドを使用して、古いページに戻るのではなく新しいページをスタックに追加しているため、アニメーションは異なります (後方ではなく前方) 。メインページに移動する必要がある場合は、profileNavigator.resetToPageメソッドの使用を検討してください。

$scope.openAboutMeDesc = function (aboutMe) {
  profileNavigator.resetToPage('profile-aboutme-desc.html', { animation : 'slide' } );
}; 

「slide」、「simpleslide」、「lift」、「fade」、「none」の間でトランザクション アニメーションを選択できることに注意してください。

不明な点がある場合は、公式ドキュメントを参照してください。

https://onsen.io/reference/ons-navigator.html

それが役に立てば幸い!

于 2015-12-30T13:56:08.520 に答える