我試圖去使用$state.go
頁面(模板)。
控制器
.controller('NavCtrl', function($scope, $location, $state) {
$scope.openDaily = function() {
$state.go('daily');
};
})
它的工作原理,但只有一毫秒或東西,因爲它是回到'/select'
頁面重定向因爲$state.otherwise
是這麼說的。
app.js
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('select', {
url: '/select',
templateUrl: 'templates/select.html',
controller: 'selectController'
})
.state('daily', {
url: '/daily',
templateUrl: 'templates/daily.html',
controller: 'dailyController'
});
$urlRouterProvider.otherwise('/select');
})
是什麼原因造成這個好嗎?
UPDATE
的index.html
<body ng-app="starter" animation="slide-left-right-ios7">
<ion-nav-view>
</ion-nav-view>
</body>
select.html
<ion-view title="Select" ng-controller="NavCtrl">
<ion-content>
<div class="list-card" ng-click="openDaily()">
<a href='#' class="item item-icon-left">
<i class="icon ion-home"></i>
Personal
</a>
</div>
</ion-content>
<div class="bar bar-footer bar-balanced">
<div class="title">Add File/Folder</div>
</div>
</ion-view>
和daily.html(模板):
<ion-view title="Select" ng-controller="NavCtrl">
</ion-view>
使用Ionic Framework。
你在錨標籤上有'ng-click =「openDaily()」?你能否在問題 –
中添加openDaily的用法,你是否可以用'html'代碼片段更新你的問題? – Miqe
在你的運行塊中實現一個狀態改變錯誤處理程序,並在那裏獲得關於什麼問題的更多細節。 – charlietfl