Skip to content

Instantly share code, notes, and snippets.

@sdbeng
Created November 4, 2015 23:19
Show Gist options
  • Select an option

  • Save sdbeng/3072eedd4e5258cdc513 to your computer and use it in GitHub Desktop.

Select an option

Save sdbeng/3072eedd4e5258cdc513 to your computer and use it in GitHub Desktop.
posting to entries to Firebase database Url
'use strict';
app.controller('FormController', ['$scope','AuthSvc','$firebaseArray','FirebaseUrl','$location','toaster', function($scope, AuthSvc, $firebaseArray, FirebaseUrl, $location, toaster){
//code form
$scope.message = " form version 0.9 - Note: if Policy Agreement is not checked, presenter can't submit paper. ";
var ref = new Firebase(FirebaseUrl);
//create a node name 'calls' and return an array
var allCalls = $firebaseArray(ref.child('calls'));
$scope.calls = allCalls;
$scope.postCall = function(call){
console.log('PostCall was called...');
//save in fb database
$scope.checkedboxClicked = true;
// call.time = Firebase.ServerValue.TIMESTAMP;
// var conv_date = new Date((call.time) * 1000);
// console.log('my time is: '+ conv_date.toJSON());
//try setting getTime to create the time node - optionally set it to Firebase.ServerValue.TIMESTAMP to avoid zone times!
// call.time = new Date().getTime(); //ex. 1446400042436 (13 digits) - 3 mre than the usual timestamp
// var mydate = call.time.toDateString();
// console.log('date to string is: '+ mydate);
//test5
// call.time = new Date(Firebase.ServerValue.TIMESTAMP);
call.time = (Firebase.ServerValue.TIMESTAMP).toString();
console.log(call.time);
$scope.calls.$add(call);
console.log(call);
$location.path('/thankyou');
console.log('Saved a new valid call for papers entry.');
//clean up form
// $scope.calls = '';
};
}]);
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment