我正在尝试使用$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');
})请问是什么原因造成的?
更新
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框架。
发布于 2016-09-08 14:37:02
请从href='#'标签中删除<a>。因为这将调用默认状态(这里是select状态)。
发布于 2016-09-08 12:44:46
看起来像是缓存问题,因为一切看起来都是正确的,请确保浏览器检查器上的文件已被更改,并且控制台上的任何内容都已损坏。
P.S:你也可以使用ui-sref="daily",如果你只想转到页面上。
https://stackoverflow.com/questions/39390552
复制相似问题