में वैश्विक चर बनाने के लिए कैसे करें मुझे यह समस्या है जब आप पंजीकरण करते हैं तो आप उपयोगकर्ता पेज पर जाते हैं। और उसके कहने के लिए "आपका स्वागत है" उपयोगकर्ता नाम के बारे में निश्चित नहीं कारण im के लिए वेब पेज पर के लिए दिखाई ... कृपया यहाँ मदद dosent लगता plunkr है:कोणीय जेएस
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
क्षमा करें। इस तरह का सवाल बंद होना चाहिए। इसका उत्तर देने के कई तरीके हैं। –