[英]ionic $scope.go not working on device
Have configured a new project on latest ionic with blank template 已使用空白模板在最新ionic上配置了一个新项目
$state.go('post.request'); $ state.go( 'post.request'); in LoginCtrl is working in browser but not when I run on phone (S4 android 5.0)
LoginCtrl中的代码正在浏览器中工作,但当我在手机上运行时无法正常工作(S4 android 5.0)
Have checked logcat for any errors but its clean. 检查logcat是否有任何错误,但干净。
This is the template 这是模板
<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>
the controller 控制器
angular.module('hrc.controllers', [])
.controller('LoginCtrl', function ($scope, $state) {
$scope.checkLogin = function () {
$state.go('post.request');
};
})
.controller('RequestCtrl', function ($scope) {
console.log("request");
});
And app file 和应用程序文件
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');
});
Your template URL must be relative : 您的模板网址必须是相对的:
"/t/post/request.html" => "t/post/request.html"
Explanation here : 在这里说明:
Using Angular UI-Router with Phonegap 在Phonegap中使用Angular UI-Router
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.