angularjs - Firebase: Error: Key content was undefined. Cannot pass undefined in JSON. Use null instead." -
trying firebase first time. got whole thing working in plunkr here: http://plnkr.co/3wirbn
var app = angular.module('myapp',['firebase']); app.factory('chatmessages',["$firebasearray",function($firebasearray){ var ref = new firebase('https://scanapp.firebaseio.com/tut'); return $firebasearray(ref); }]); app.controller('mycontroller'['$scope','chatmessages',function($scope,chatmessages){ $scope.test = 'hello world'; $scope.user = "anonymouse"; $scope.messages = chatmessages; $scope.addmessage = function(){ $scope.messages.$add({ from: $scope.user, content: $scope.message }); $scope.message = ''; }; }]);
i tried following tutorials on site, did quick start stuff read docs thoroughly, keep getting error above:
"error: key content undefined. cannot pass undefined in json. use null instead."
i can working in above plunk, understand concepts. copied same code plunk, , cdn links project, same error. im using ionic framework web-based app. angular , still working fine,i error when trying hit "add" button run function.
update: has inputs. if set "from" , "content" key , field strings rather bound $scope, works:
$scope.addmessage = function(){ $scope.messages.$add({ from: 'test', content: 'stuff' }); $scope.message = ''; };
but isn't useful other sending same data on , on again.
you have $scope.messages in form. form creates new scope. remove form , replace button following:<button ng-click="addmessage()">add</button>
doesn't create new scope , message added firebase. @ least worked me.
Comments
Post a Comment