小编Ale*_*hes的帖子

用户使用Angularjs和Firebase登录

我正在尝试使用Angularjs和Firebase创建一个简单的登录表单.我目前有一个简单的注册表单,它将userName添加到我的firebase数据库中.我需要知道的是,一旦在firebase系统中识别出userName,如何获得一个接受用户的登录页面,如果数据库中没有这样的userName,可能会产生回调错误.这是我的注册表格:

<html ng-app="myApp">
<body ng-controller="userCtrl">
    <div class="centerForm">

        <form>
          <div class="form-group">
            <label for="exampleInputUser">Username</label>
            <input type="username" ng-model="userName" class="form-control" id="exampleInputUser" placeholder="username">
          </div>
          <div class="form-group">
            <label for="exampleInputPassword1">Password</label>
            <input type="password" ng-model="userPassword" class="form-control" id="exampleInputPassword1" placeholder="Password">
          </div>
          <table class="nav" align="center">
            <tr>
                <td>
                    <p><button type="submit" class="btn btn-primary" ng-click="saveUser()">Submit</button>
                    <a href="#" class="btn btn-info" role="button">Sign Up</a></p>
                </td>
            </tr>       
          </table>
        </form>

    </div>  
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我的注册码:

 <script>
             angular.module('myApp', [])
             .controller('userCtrl', function($scope) {
                $scope.userName ="";
                $scope.userPassword="";

                $scope.myData = new Firebase( "https://myfirebaseapp.firebaseio.com/")

                $scope.saveUser = function() {
                    $scope.myData.push({userName: $scope.userName});
                };

                });





    </script> 
Run Code Online (Sandbox Code Playgroud)

我的登录表单看起来像:

<html ng-app="myApp"> …
Run Code Online (Sandbox Code Playgroud)

angularjs firebase angularfire

-1
推荐指数
1
解决办法
7330
查看次数

标签 统计

angularfire ×1

angularjs ×1

firebase ×1