从登录到另一个状态的简单导航在浏览器中工作,但在Android设备上打破,在这种情况下的任何想法我检查什么?因为我在浏览器中没有任何错误,我在设备上运行时没有任何日志,所以我该如何调试?
app.js:
=======
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
var ionicApp = angular.module('feedback-system', ['ionic', 'firebase', 'coursesModule', 'feedbackModule', 'loginModule', 'servicesModule', 'tabsModule', 'notificationModule', 'addCoursesModule']);
ionicApp.run(function($ionicPlatform, $state, $location, $rootScope, $localstorage) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams)
{
if($localstorage.get('login') == 'false')
{
$location.path('/login');
// $state.go('login');
}
});
});
ionicApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'views/login.html',
controller: 'loginCtrl'
})
.state('tabs', {
url: '/tabs',
abstract: true,
templateUrl: 'views/main.html',
controller: 'tabsCtrl'
})
.state('tabs.courses', {
url: '/courses',
views:{
'coursesView':{
templateUrl: 'views/courses.html',
controller: 'coursesCtrl'
}
}
})
.state('tabs.feedback', {
url: '/feedback',
views:{
'feedbackView':{
templateUrl: 'views/feedback.html',
controller: 'feedbackCtrl'
}
}
})
.state('tabs.notifications', {
url: '/notifications',
views:{
'notificationsView':{
templateUrl: 'views/notification.html',
controller: 'notificationCtrl'
}
}
})
$urlRouterProvider.otherwise("/tabs/courses");
});
var servicesModule = angular.module('servicesModule', ['ionic', 'ngCordova']);
servicesModule.factory('$localstorage', ['$window', function($window) {
return {
set: function(key, value) {
$window.localStorage[key] = value;
},
get: function(key) {
return $window.localStorage[key] || undefined;
},
setObject: function(key, value) {
$window.localStorage[key] = JSON.stringify(value);
},
getObject: function(key) {
return JSON.parse($window.localStorage[key] || '{}');
}
}
}]);
servicesModule.service('firebaseReferenceService', ['$state', function($state){
var ref = new Firebase("https://feedback-system.firebaseio.com/");
return {firebaseMainAppObjectReference: ref};
}]);
servicesModule.service('loginService', ['$state', '$localstorage', function($state, $localstorage){
var ref = new Firebase("https://feedback-system.firebaseio.com/");
var authData = ref.getAuth();
if (authData) {
$localstorage.set('login', 'true');
$state.go('tabs.courses');
console.log("User " + authData.uid + " is logged in with " + authData.provider);
} else {
$state.go('login');
}
}]);
servicesModule.service('usernameParsingService' , ['$state', '$localstorage', function($state, $localstorage){
var ref = new Firebase("https://feedback-system.firebaseio.com/");
var authData = ref.getAuth();
var userauthen = authData.uid;
var emailid = authData.password.email.replace(/@.*/,'');
var completeemail = authData.password.email;
var stuOrAd = completeemail.includes("student");
var ln = userauthen.length;
userauthen = emailid + userauthen.charAt(ln-1);
var str = userauthen.split(".");
userauthen = "";
for (i=0; i<str.length; i++)
{
userauthen = userauthen + str[i];
}
console.log('stuOrAd : ' + stuOrAd);
console.log('userauthen : ' + userauthen);
return {userid: userauthen ,
checker: stuOrAd};
}]);
答案 0 :(得分:1)
我也曾犯过这样的错误。
所有州名,文件夹名称和页面区分大小写。 您应该检查州名,文件夹或页面名称案例(大写或小写字母)。
它可以在浏览器中运行,但在设备上部署时会失败。
希望这会有所帮助