好的,现在我不会在这里找不到这个概念。当我从registratoin.html删除所有内容时,结果实际上没有发生什么? #/要去哪里?我很困惑......
这是我的index.html:
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="jquery.js"></script>
<script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular-route.js"></script>
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.js"></script>
<script src = "http://s.codepen.io/assets/libs/modernizr.js"></script>
<script type="text/javascript" src="script.js"></script>
<meta charset="UTF-8">
<meta name="X-UA-Compatible" content="">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="keywords" content="">
<meta name="description" content="">
<title>Login - UniqueCoders</title>
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="main.css">
</head>
<body ng-app="LoginApp">
<div id="page">
<header class="container">
</header>
<div ng-view>
<main class="container">
<div class="row login">
<form ng-controller="AuthCtrl">
<input type="email" name="email" placeholder="Email" ng-model = "email" id="email">
<input type="password" name="password" ng-model="password" placeholder="Password" id="password">
<input type="submit" value="Sign Up" ng-click="createUser()">
</form>
<a href = "#/logIn">Want to Log In?</a>
</div>
</main>
</div>
<footer class="container">
<div class="row">
<small>© 2016. Unique Coders</small>
</div>
</footer>
</div>
</body>
</html>
这是我的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',
})
.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;
Auth.$createUser({
email: $scope.email,
password: $scope.password
}).then(function(userData) {
$scope.message = "User created with uid: " + userData.uid;
}).catch(function(error) {
$scope.error = error;
if(error = 'INVALID_EMAIL'){
alert("The Email you entered is Invalid")
}
else if(error = "INVALID_PASSWORD"){
alert("The Password you entered is Invalid")
}
else if(error = "EMAIL_TAKEN"){
console.log("The Email you entered is taken. Please Log In")
}
else{
alert(error)
}
});
};
/* $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;
});
};*/
}
]);
这是我的registration.html:
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="jquery.js"></script>
<script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular-route.js"></script>
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.js"></script>
<script src = "http://s.codepen.io/assets/libs/modernizr.js"></script>
<script type="text/javascript" src="script.js"></script>
<meta charset="UTF-8">
<meta name="X-UA-Compatible" content="">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="keywords" content="">
<meta name="description" content="">
<title>Login - UniqueCoders</title>
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="main.css">
</head>
<body >
<div id="page">
<header class="container">
<div class="row">
<img src="https://lh5.googleusercontent.com/-UXr_le-DEc4/VogTLE2yDfI/AAAAAAAAAfI/9RycRDVGNu8/w993-h207-no/uniquecoders.png" alt="UniqueCoders">
</div>
</header>
<main class="container">
<div class="row login">
<form >
<input type="email" name="email" placeholder="Email" ng-model = "email" id="email">
<input type="password" name="password" ng-model="password" placeholder="Password" id="password">
<input type="submit" value="Sign Up" ng-click="createUser()">
</form>
<a href = "#/logIn">Want to Log In?</a>
</div>
</main>
</div>
<footer class="container">
<div class="row">
<small>© 2016. Unique Coders</small>
</div>
</footer>
</body>
</html>