Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created January 4, 2014 21:18
Show Gist options
  • Save telagraphic/8260844 to your computer and use it in GitHub Desktop.
Save telagraphic/8260844 to your computer and use it in GitHub Desktop.
Angular on Fire
var app = angular.module('myApp', [
'ngRoute',
'myApp.services',
'myApp.directives',
'myApp.filters',
'myApp.controllers',
'firebase'
]);
Error: 'undefined' is not a function (evaluating '$firebase(fireBase)');
It is complaining about this line in my controller:
$scope.bets = $firebase(fireBase);
angular.module('myApp.controllers', [])
.controller('BettingController', ["$scope", "$firebase", function($scope, CurrentDate, $firebase) {
//$scope.today = CurrentDate.getCurrentDate();
var fireBase = new Firebase("https://flowbetter.firebaseio.com");
$scope.bets = $firebase(fireBase);
$scope.newBet = {};
$scope.saveBet = function() {
$scope.bets.$add($scope.newBet);
$scope.newBet = "";
};
}]).controller('ResultsController', ['$scope', function($scope) {
$scope.firstName = "Nick Name";
}]);
<!doctype html>
<html lang="en" ng-app="myApp" ng-csp>
<head>
<meta charset="utf-8">
<title>Flow Better</title>
<link rel="stylesheet" href="css/normalize.css"/>
<link rel="stylesheet" href="css/app.css"/>
<link rel="stylesheet" href="css/csp.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script src="lib/angular-route.js"></script>
<script src='https://cdn.firebase.com/v0/firebase.js'></script>
<script src='https://cdn.firebase.com/libs/angularfire/0.5.0/angularfire.min.js'></script>
<meta name="viewport" content="width=device-width">
</head>
<body>
<div ng-controller="BettingController">
{{ today }}
<form>
<input type="text" ng-model="newBet.better">
<input type="datetime" ng-model="newBet.startTime">
<input type="datetime" ng-model="newBet.timeLength">
<input type="submit" placeholder="Place Bet" ng-click="saveBet();">
<form>
<ul ng-repeat="bet in bets">
<li>{{bet.better}}</li>
</ul>
</div>
<div ng-controller="ResultsController">
{{firstName}}
</div>
<!-- Library files -->
<!-- App files -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/directives.js"></script>
<script src="js/filters.js"></script>
<script src="js/services.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment