У меня есть эта проблема, когда при регистрации вы попадаете на страницу «Пользователи». И его предположим, сказать: «Добро пожаловать» Имя пользователя, доцент показать на на веб-странице по причине им не уверен ... пожалуйста, помогите здесь является plunkr:Как сделать глобальные переменные в angularJS
http://plnkr.co/edit/qB3Gkeq5ji1YQyy0kpGH?p=preview
Пожалуйста, мне нужна помощь ..
мне нужно получить код для plunker так: script.js:
var app = angular.module('LoginApp', ["firebase", "ngRoute"])
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'registration.html',
controller: 'AuthCtrl'
})
.when('/logIn', {
templateUrl: 'login.html',
controller: 'AuthCtrl'
})
.when('/User', {
templateUrl: "User.html",
controller: 'AuthCtrl'
})
.otherwise({
redirectTo: '/'
});
});
app.factory("Auth", ["$firebaseAuth",
function($firebaseAuth) {
var ref = new Firebase("https://uniquecoders.firebaseio.com/");
return $firebaseAuth(ref);
}
]);
app.controller("AuthCtrl", ["$scope", "Auth",
function($scope, Auth) {
$scope.createUser = function() {
$scope.message = null;
$scope.error = null;
var ref2 = new Firebase("https://uniquecoders.firebaseio.com/");
ref2.createUser({
email: $scope.email,
password: $scope.password
}, function(error, userData) {
if (error) {
switch (error.code) {
case "EMAIL_TAKEN":
alert("The new user account cannot be created because the email is already in use. Try to login");
break;
case "INVALID_EMAIL":
alert("The specified email is not a valid email.");
break;
case "INVALID_PASSWORD":
alert("The Specified Passowrd Is not valid.")
break;
default:
alert("Error creating user:", error);
}
} else {
alert("Successfully created user account with uid:", userData.uid);
alert($scope.UserName)
window.location.hash = "/User"
$scope.usernames = "HEY"
}
});
};
$scope.logIn = function(){
$scope.message = null;
$scope.error = null;
ref2.authWithPassword({
"email" : $scope.logInemail,
"password" : $scope.logInemailpassword
}, function(error, userData){
if(error){
alert("Login Failed.")
console.log(error)
}
else{
alert("Logged In!")
}
})
}
/* $scope.removeUser = function() {
$scope.message = null;
$scope.error = null;
Auth.$removeUser({
email: $scope.email,
password: $scope.password
}).then(function() {
$scope.message = "User removed";
}).catch(function(error) {
$scope.error = error;
});
};*/
}
]);
Я думаю, вам нужно изучить больше о Угловое: https://docs.angularjs.org/guide ищите службы и сферу действия. –
@ ViníciusFagundes вы можете помочь мне thoguh? – amanuel2
Извините. этот вопрос должен быть закрыт. Есть несколько способов ответить на него. –