Ich teste eine ionische App in meinem Android-Handy. Ich verwende eine rootScope-Funktion, um die Sitzung eines Benutzers zu überprüfen, und diese Funktion zeigt einen TypeError in der Chrome-Debug-Konsole an ("TypeError: $ rootScope.checkSession ist keine Funktion") http://www.raymondcamden.com/2014/08/16/Ionic-and-Cordovas-DeviceReady-My-Solution/ aber ich habe nicht ruhig das Konzept bekommen. Ich würde mich freuen, wenn du helfen könntest. Vielen Dank!rootScope-Funktionen im .run-Modul werden nicht erkannt
Hier ist mein Code:
forkapp.run(function($ionicPlatform, $rootScope, $firebaseAuth, $firebase, $window, $ionicLoading) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
var fb = new Firebase("https://glowing-torch-9862.firebaseio.com/");
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
$rootScope.userEmail = null;
$rootScope.baseUrl = 'https://glowing-torch-9862.firebaseio.com/';
var authRef = new Firebase($rootScope.baseUrl);
$rootScope.auth = $firebaseAuth(authRef);
$rootScope.show = function(text) {
$rootScope.loading = $ionicLoading.show({
content: text ? text : 'Loading..',
animation: 'fade-in',
showBackdrop: true,
maxWidth: 200,
showDelay: 0
});
};
$rootScope.hide = function() {
$ionicLoading.hide();
};
$rootScope.notify = function(text) {
$rootScope.show(text);
$window.setTimeout(function() {
$rootScope.hide();
}, 1999);
};
$rootScope.logout = function() {
$rootScope.auth.$logout();
$rootScope.checkSession();
};
$rootScope.checkSession = function() {
var auth = new FirebaseSimpleLogin(authRef, function(error, user) {
if (error) {
// no action yet.. redirect to default route
$rootScope.userEmail = null;
$window.location.href = '#/auth/signin';
} else if (user) {
// user authenticated with Firebase
$rootScope.userEmail = user.email;
$window.location.href = ('#/event');
} else {
// user is logged out
$rootScope.userEmail = null;
$window.location.href = '#/auth/signin';
}
});
};
}); //ionic platform ready
})
sein könnte, weil '$ rootScope.checkSession();' in 'logout' verwendet wird, bevor es definiert wurde. – Daniel