0
我們使用以顯示網頁內容滑動菜單中ONSEN UI & Navigator在它。 現在我們想通過按下PHONE BACK KEY來阻止關閉應用程序,而是將其重定向到主頁,如果用戶root是主頁,則顯示一條警告文本「您是否想要關閉應用程序? {沒有}」。定製手機背部按鈕,在溫泉UI
我的index.html:
<ons-sliding-menu ng-if="!firstInit" menu-page="menu.html" side="right" main-page="home.html"
var="menu" type="push" swipe-target-width="150px" max-slide-distance="220px" swipeable="true">
</ons-sliding-menu>
我menu.html:
<ons-list-item modifier="tappable nodivider" ng-click="menu.setMainPage('home.html', {closeMenu: true})">
<p class="menu-text"><i class="fa fa-home fa-fw "></i>Home</p>
</ons-list-item>
<ons-list-item modifier="tappable nodivider" ng-click="menu.setMainPage('bill.html', {closeMenu: true})">
<p class="menu-text"><i class="fa fa-barcode fa-fw "></i>Enter Code</p>
</ons-list-item>
<ons-list-item modifier="tappable nodivider" ng-click="menu.setMainPage('account.html', {closeMenu: true})">
<p class="menu-text"><i class="fa fa-user fa-fw "></i>Login</p>
</ons-list-item>
<ons-list-item modifier="tappable nodivider" ng-click="menu.setMainPage('location.html', {closeMenu: true})">
<p class="menu-text"><i class="fa fa-map-o fa-fw "></i>Show On Map</p>
</ons-list-item>
我home.html的:
<ons-navigator var="myNavigator" animation="none">
<ons-page ons-init="menu.setSwipeable(true)" on-device-backbutton="alert('Test!!!')">
.
.
.
<div class="box" ng-click="myNavigator.pushPage('cafe-details.html', {data: {cafeID: cafeItem.ID}})">
<div class="ribbon">
<span ng-show="cafeItem.IsSpecial">Offer</span>
</div>
<p>{{cafeItem.Name}}<br>
<i class="fa fa-map-marker fa-1x"></i>{{cafeItem.Address_Title}}</p>
<img class="img-responsive" ng-src="{{CafeImageURL}}{{cafeItem.Image[0].Image}}" loading-src="/images/cafe-no.jpg" fallback-src="/images/cafe-no.jpg" />
<span class="caption full-caption">
<i class="fa fa-eye"><a class="number"> {{cafeItem.Views}} </a></i>
<i class="fa fa-comments-o"><a class="number"> {{cafeItem.Comments}} </a></i>
<i class="fa fa-thumbs-o-up" id="likes"><a class="number"> {{cafeItem.Likes}} </a></i>
<i class="fa fa-thumbs-o-down" id="dislikes"><a class="number"> {{cafeItem.Dislikes}} </a></i>
</span>
</div>