【发布时间】:2015-05-17 21:55:33
【问题描述】:
已经用空白模板在最新的 ionic 上配置了一个新项目
$state.go('post.request');在 LoginCtrl 中的浏览器中工作,但不是当我在手机上运行时(S4 android 5.0)
检查了 logcat 是否有任何错误,但它是干净的。
这是模板
<div class="bar bar-header bar-assertive">
<h1 class="title">HRC Karaoke</h1>
</div>
<div class="list padding has-header">
<button class="button button-stable fullwidth" ng-click="checkLogin();">
Login with Facebook
</button>
</div>
控制器
angular.module('hrc.controllers', [])
.controller('LoginCtrl', function ($scope, $state) {
$scope.checkLogin = function () {
$state.go('post.request');
};
})
.controller('RequestCtrl', function ($scope) {
console.log("request");
});
还有应用文件
angular.module('hrc', ['ionic', 'hrc.controllers', 'ui.router'])
.run(function ($rootScope, $state) {
})
.config(function ($stateProvider, $urlRouterProvider, $stateProvider) {
$stateProvider
.state('pre', {
url: "/pre",
abstract: true,
views: {
'main': {
templateUrl: "t/pre/pre.html",
controller: "StartCtrl"
}
}
})
.state('pre.login', {
url: "/login",
views: {
'preContent': {
templateUrl: "t/pre/login.html",
controller: "LoginCtrl"
}
}
})
.state('post', {
url: "/post",
abstract: true,
views: {
'main': {
templateUrl: "t/post/post.html",
controller: "PostCtrl"
}
}
})
.state('post.request', {
url: "/request",
views: {
'postContent': {
templateUrl: "/t/post/request.html",
controller: "RequestCtrl"
}
}
})
$urlRouterProvider.otherwise('/pre/login');
});
【问题讨论】:
-
checklogin函数被触发了吗?
标签: android cordova angular-ui-router ionic-framework ionic