路由在我的應用程序的設置如下:路由不離子應用工作
$stateProvider
.state('app', {
url: '',
abstract: true,
template: '<ion-nav-view></ion-nav-view>'
});
$stateProvider
.state('app.todos', {
url: '/home',
views: {
todos: {
templateUrl: 'home.html',
controller: 'TodosCtrl'
}
}
});
$stateProvider
.state('app.help', {
url: '/help',
views: {
help: {
templateUrl: 'help.html'
}
}
});
$urlRouterProvider.otherwise('/home');
//index.html
<body>
<ion-nav-bar class="bar-positive"> </ion-nav-bar>
<ion-tabs class="tabs-positive">
<ion-tab icon="ion-checkmark" ui-sref="app.todos">
<ion-nav-view name="todos"></ion-nav-view>
</ion-tab>
<ion-tab icon="ion-help" ui-sref="app.help">
<ion-nav-view name="help"></ion-nav-view>
</ion-tab>
</ion-tabs>
<script type="text/ng-template" id="home.html">
<ion-view title="Todos">
<ion-content padding="true">
<h2>Home Page</h2>
<p>Here's the main route for the app.</p>
</ion-content>
</ion-view>
</script>
<script type="text/ng-template" id="help.html">
<ion-view title="Help">
<ion-content padding="true">
<h2>Using the app</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis architecto hic officia quasi excepturi sequi deleniti maiores consectetur veritatis sint?</p>
</ion-content>
</ion-view>
</script>
</body>
在應用程序的開始,我希望國家app.todos到變爲活動並顯示相應的模板。
這沒有發生。
Plnkr可在這裏: http://plnkr.co/edit/LDNLHx?p=preview
如何鏈接到這條路線?我以爲我注意到了一個無效的錨標籤...你能告訴我們鏈接到朋友頁面的代碼嗎? – Makoto
不確定您是否打開了正確的plnkr – runtimeZero
繼續並在此發佈您的tabs.html文件,我會告訴你我的意思。 – Makoto