我得到了ReferenceError:在AngularJS中将数据推送到Firebase数据库期间没有定义Firebase?

时间:2017-07-25 17:29:54

标签: angularjs firebase firebase-realtime-database angularfire

如何解决此错误?

//Here this is our controller code
var app = angular.module("myApp", ["firebase"]);
	app.controller("myCtrl", function($scope, $firebase, $firebaseObject) {

	$scope.submitData = function() {
		var name = $scope.user;
		var pass = $scope.password;
		var firebaseObj = new Firebase("https://angulardemo-72e92.firebaseio.com/");
            var fb = $firebase(firebaseObj);

        fb.$push({ Name: name,Password: pass}).then(function(ref) {
            console.log(ref);
        }, function(error) {
            console.log("Error:", error);
        });
	}	

});
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
  <script src="firebase.js"></script>
  <script src="angularfire.min.js"></script>
  <script src="app.js"></script>
  <script>
	  // Initialize Firebase
	  var config = {
	    apiKey: "AIzaSyBQksCCUXGkotmwBDSPUBfQvIC-xt9p5DY",
	    authDomain: "angulardemo-72e92.firebaseapp.com",
	    databaseURL: "https://angulardemo-72e92.firebaseio.com",
	    projectId: "angulardemo-72e92",
	    storageBucket: "angulardemo-72e92.appspot.com",
	    messagingSenderId: "230268694130"
	  };
  	firebase.initializeApp(config);
</script>
	<body>
		<div ng-app="myApp" ng-controller="myCtrl">
			Enter Name<input type="text" ng-model="user"><br>
			Enter Passwrod <input type="text" ng-model="password">
			<button type="sumbit" name="sumbit" value="sumbit" ng-click="submitData()">LOGIN</button> 
		</div>
	</body>
</html>

您好先生,我必须将数据推送到firebase数据库但是我得到一个错误firebase未定义,在AngularJS中请告诉我我的代码中有什么问题?

0 个答案:

没有答案