我试图在访问
后启用后退按钮科学事实->更多事实->洞察类型1">
但是<ion-nav-back-button祝辞点击"洞察类型1"后停止工作。>
我的应用程序需要浏览器多级导航视图,从"#/tab/home"#/标签/facts2/insights1"。
我试着做了一些改变,发现它可以工作,如果我这样做:
<a class="button icon icon-right ion-chevron-right" ui-sref="tabs.facts2">More Facts</a>
<a class="button icon icon-right ion-chevron-right" ui-sref="tabs.facts2.insights1">More Facts</a>
不幸的是,我不能直接访问insights1和insights2,因为我需要在tabs.facts2中接收用户交互。
我的代码也可以在codependency访问此链接。
谁知道怎么修理它?
angular.module('ionicApp', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tabs', {
url: "/tab",
abstract: true,
templateUrl: "templates/tabs.html"
})
.state('tabs.home', {
url: "/home",
views: {
'home-tab': {
templateUrl: "templates/home.html",
controller: 'HomeTabCtrl'
}
}
})
.state('tabs.facts', {
url: "/facts",
views: {
'home-tab': {
templateUrl: "templates/facts.html"
}
}
})
.state('tabs.facts2', {
url: "/facts2",
views: {
'home-tab': {
templateUrl: "templates/facts2.html"
}
}
})
.state('tabs.facts2.insights1', {
url: "/insights1/",
views: {
'insights-tab': {
templateUrl: "templates/insights1.html"
}
}
})
.state('tabs.facts2.insights2', {
url: "/insights2/",
views: {
'insights-tab': {
templateUrl: "templates/insights2.html"
}
}
})
.state('tabs.about', {
url: "/about",
views: {
'about-tab': {
templateUrl: "templates/about.html"
}
}
})
.state('tabs.navstack', {
url: "/navstack",
views: {
'about-tab': {
templateUrl: "templates/nav-stack.html"
}
}
})
.state('tabs.contact', {
url: "/contact",
views: {
'contact-tab': {
templateUrl: "templates/contact.html"
}
}
});
$urlRouterProvider.otherwise("/tab/home");
})
.controller('HomeTabCtrl', function($scope) {
console.log('HomeTabCtrl');
});
<link href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Tabs Example</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
</head>
<body>
<ion-nav-bar class="bar-positive">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view></ion-nav-view>
<script id="templates/tabs.html" type="text/ng-template">
<ion-tabs class="tabs-icon-top tabs-positive">
<ion-tab title="Home" icon="ion-home" href="#/tab/home">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab>
<ion-tab title="About" icon="ion-ios-information" href="#/tab/about">
<ion-nav-view name="about-tab"></ion-nav-view>
</ion-tab>
<ion-tab title="Contact" icon="ion-ios-world" ui-sref="tabs.contact">
<ion-nav-view name="contact-tab"></ion-nav-view>
</ion-tab>
</ion-tabs>
</script>
<script id="templates/home.html" type="text/ng-template">
<ion-view view-title="Home">
<ion-content class="padding">
<p>
<a class="button icon icon-right ion-chevron-right" href="#/tab/facts">Scientific Facts</a>
</p>
</ion-content>
</ion-view>
</script>
<script id="templates/facts.html" type="text/ng-template">
<ion-view view-title="Facts">
<ion-content class="padding">
<p>Banging your head against a wall uses 150 calories an hour.</p>
<p>
<a class="button icon ion-home" href="#/tab/home"> Home</a>
<a class="button icon icon-right ion-chevron-right" ui-sref="tabs.facts2">More Facts</a>
</p>
</ion-content>
</ion-view>
</script>
<script id="templates/facts2.html" type="text/ng-template">
<ion-view view-title="Also Factual">
<ion-content class="padding">
<div class="button-bar">
<a class="button" nav-transition="none" ui-sref="tabs.facts2.insights1"> Insights Type 1</a>
<a class="button" nav-transition="none" ui-sref="tabs.facts2.insights2"> Insights Type 2</a>
</div>
<ion-nav-view name="insights-tab"></ion-nav-view>
</ion-content>
</ion-view>
</script>
<script id="templates/insights1.html" type="text/ng-template">
<ion-view view-title="Insights1">
<ion-content class="padding">
<p>HELLO WORLD 1</p>
</ion-content>
</ion-view>
</script>
<script id="templates/insights2.html" type="text/ng-template">
<ion-view view-title="Insights2">
<ion-content class="padding">
<p>HELLO WORLD 2</p>
</ion-content>
</ion-view>
</script>
<script id="templates/about.html" type="text/ng-template">
<ion-view view-title="About">
<ion-content class="padding">
<h3>Create hybrid mobile apps with the web technologies you love.</h3>
<p>Free and open source, Ionic offers a library of mobile-optimized HTML, CSS and JS components for building highly interactive apps.</p>
<p>Built with Sass and optimized for AngularJS.</p>
<p>
<a class="button icon icon-right ion-chevron-right" href="#/tab/navstack">Tabs Nav Stack</a>
</p>
</ion-content>
</ion-view>
</script>
<script id="templates/nav-stack.html" type="text/ng-template">
<ion-view view-title="Tab Nav Stack">
<ion-content class="padding">
<p><img src="https://ionicframework.com/img/diagrams/tabs-nav-stack.png" style="width:100%"></p>
</ion-content>
</ion-view>
</script>
<script id="templates/contact.html" type="text/ng-template">
<ion-view title="Contact">
<ion-content>
<div class="list">
<div class="item">
@IonicFramework
</div>
<div class="item">
@Cordova
</div>
</div>
</ion-content>
</ion-view>
</script>
</body>
</html>
逻辑上的缺陷在于都在导航栏的顶层。
当你需要嵌套"见解"时;插入"facts",并使用嵌套的子路由(可以注意到脚本在哪里中断)。虽然很难告诉更多,除非能够看到路由器的调试输出。