0
イオンクリエイターを使用すると、ログイン/ログアウト時に私のサイドメニュー情報(アバター、ユーザー名...)が以前のユーザーの情報を保持するテストする2つのアカウント間の切り替え)。前のユーザーに関連するすべての情報を更新または削除する方法、次のメニューのためにサイドメニューを更新する方法がわかりません。コンソールで正しい値がロードされていることがわかりますが、メニューの前の値は消去されません。ログイン/ログアウト後にイオンサイドメニューのデータをリフレッシュできない
提案がありますか?
// SIGNOUT FUNCTION in the controller
$scope.signOut = function(){
firebase.auth().signOut().then(function() {
// This is to try to "clean" "clear" all informations of the previous user
$ionicLoading.show({
template: 'Logging out....'
});
$timeout(function() {
$ionicLoading.hide();
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
$ionicHistory.nextViewOptions({
disableBack: true,
historyRoot: true
});
$state.go("connexion");
}, 30);
});
};
// MAJ DOM (menu) FUNCTION in the controller
// function used for refresh the menu informations (avatar, displayname...)
$scope.majDom = function()
{
//$state.reload();
var user = firebase.auth().currentUser;
var uid;
$scope.userData = user;
if (user !== null) {
$scope.userData.displayName = user.displayName;
$scope.userData.email = user.email;
$scope.userData.avatar = user.photoURL;
uid = user.uid;
//With these lines, I can read in the console that the right informations are loaded after a new login, but never appear in the menu, instead there are previous user's informations.
console.log("Avatar de l'user :", $scope.userData.avatar);
console.log("Nom de l'user :", $scope.userData.displayName);
console.log("Email de l'user :", $scope.userData.email);
}
}
// LOGIN FUNCTION in the controller
$scope.loginEmail = function($email, $password){
var alertPopup;
function signInSuccess(response) {
console.log('signInSuccess : ', response);
// This is to call a menu refresh, but dosen't work
$scope.majDom();
$state.go("menu.VNements");
}
firebase.auth().signInWithEmailAndPassword($email, $password)
.then(signInSuccess)
};
// MENU FUNCTION in the Menu Page of the creator
function ($scope, $stateParams, $state, $firebaseArray, $ionicHistory) {
//$ionicUser, $ionicAuth,
var user = firebase.auth().currentUser;
var uid;
$scope.userData = user;
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
$ionicHistory.nextViewOptions({
disableBack: true,
historyRoot: true
});
if (user !== null) {
$scope.userData.displayName = user.displayName;
$scope.userData.email = user.email;
$scope.userData.avatar = user.photoURL;
uid = user.uid;
console.log("Avatar de l'user :", $scope.userData.avatar);
console.log("Nom de l'user :", $scope.userData.displayName);
console.log("Email de l'user :", $scope.userData.email);
}
In the side menu's HTML the Avatar is called like this :
{{userData.avatar}}
And the display name :
{{userData.displayName}}
、誰もが考えを持っているしてください? – Memphis