无法与我的firebase数据库建立连接

时间:2015-08-17 14:38:25

标签: angularjs firebase

我正在尝试使用Rails,AngularJS和Firebase开发应用程序。

我已经创建了一个firebase免费帐户并开始为我的角度js控制器编写一些代码。

这是控制器: 的 chat_room.js:

 var app = angular.module('ChatRoom',["firebase"]);


app.controller('ChatCtrl',['$scope', '$http',"$firebaseArray" ,function($scope,$http,$firebaseArray){

    $scope.isConnected = false;
    $scope.UserData = {};

    var firebaseRoot =  new Firebase("https://my-firebase.firebaseio.com/");
    var connectedRef = firebaseRoot.child('.info/connected').on('value', function(connectedSnap){
        if(connectedSnap.val() === true){ 
            $scope.isConnected = true
        }
        else{ 
            $scope.isConnected = false
        }
    });

    var getUserData = function(){
        $http.get('/chat_room/show').success(
            function(item){
                $scope.UserData = item
            }); 
    }

    getUserData();

    /*var msgRef = firebaseRoot.child('chatroom/messagges');*/
    /*$scope.chat = $firebaseArray(msgRef);*/


}])

这是我的观点:

<div ng-controller="ChatCtrl">
    <div ng-show="isConnected">
      <div data-alert class="alert-box success radius">Connected to firebase =) <a href="#" class="close">&times;</a>
    </div>
</div>
  <h1>hello, {{UserData.first_name}}</h1>
  <p>Send chat from here</p>


</div>

如果我启动服务器并加载页面,连接消息没有显示,我也回复了这条消息:

控制台中的

The connection to wss://s-dal5-nss-20.firebaseio.com/.ws?v=5&ns=angular-fire-powder was interrupted while the page was loading.

我不知道该怎么做这是我第一次使用firebase和AngularJS

0 个答案:

没有答案