After struggling to get the firebase binds to work with knockoutjs, I decided to experiment with angularjs. I downloaded angularjs and started trying to manipulate some data. In my app.js file, I have the following code:
/* Controllers */
angular.module('MyCtrl3', ['$scope', 'angularFire'])
.controller ("MyCtrl3", function ($scope, angularFire) {
$scope.addMsg = function ($scope, angularFire) {
var url = 'https://kingpinapp.firebaseio.com/msgs';
var promise = angularFire(url, $scope, 'msgs', []);
$scope.msgs.push({name: "Firebase", desc: "is awesome!"});
}
});
My HTML code is simple:
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
<link rel="stylesheet" href="css/app.css"/>
<link rel="stylesheet" href="css/bootstrap.css"/>
</head>
<body>
<div>Angular seed app: v<span app-version></span></div>
<div ng-controller="MyCtrl3">
<button ng-click="addMsg()">Add</button>
</div>
<!-- bunch of scripts -->
</body>
</html>
I just want the add button to push the data to firebase. However, when I try it, I encounter this error in the console: Uncaught TypeError: Cannot call method 'push' of undefined. Here's the JSFiddle link for better understanding: http://jsfiddle.net/NHaZz/5/