我在离子1.X中构建聊天室,我想将Firebase用作我的数据库和身份验证提供程序。首先,我希望能够使用Firebase创建和登录用户。我在我的账户中启用了简单的电子邮件和密码认证然而,大多数的教程这样one作品与火力地堡2.如果我跟着它,我有一个错误:使用Firebase SDK 3与Ionic 1.X
在我的index.html我打开火力,如:
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
并创建一个用户:
$scope.signupEmail = function(){
$scope.message = null;
$scope.error = null;
console.log('In signup email with username ' + $scope.data.username + ' email ' + $scope.data.email + ' and password ' + $scope.data.password);
var chatRef = new Firebase('https://some-url.firebaseio.com');
var auth = $firebaseAuth(chatRef);
auth.$createUser({
email: $scope.data.email,
password: $scope.data.password
}).then(function(userData) {
console.log("User created with uid: " + userData.uid);
$scope.message = "User created with uid: " + userData.uid;
}).catch(function(error) {
console.log("Error: " + error);
$scope.error = error;
});
};
合乎逻辑的结论和搜索谷歌的是,我应该用火力地堡3 SDK创建一个用户。然而,官方的文档离子(而不是传统的一个),你找到任何部分与离子整合新的SDK,如果我去的index.html,并添加使用火力的新方式:
<script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "apiKey",
authDomain: "projectId.firebaseapp.com",
databaseURL: "https://databaseName.firebaseio.com",
storageBucket: "bucket.appspot.com",
};
firebase.initializeApp(config);
</script>
然后我我无法注入'firebase'到我的模块。
的如何整合火力SDK 3和离子1.x的任何想法?
非常感谢你的智慧:)它的工作! –