konzz / angular-firebase-calendar

MIT License
3 stars 5 forks source link

Quick Question #1

Open manentea opened 9 years ago

manentea commented 9 years ago

Hey, I found your tutorial and just had a quick question for you.

In these lines here

var events = $firebase(firebaseEvents);
$scope.events = [events.$asArray()];

Because we need an array of events wouldn't it be beneficial to use $firebaseArray since AngularFire provides that as well? Or is there a reason it's done this way?

manentea commented 9 years ago
.controller('calendar', ['$scope', '$firebase', function($scope, $firebaseArray){

  var firebaseEvents = new Firebase("https://{{FIREBASE URL}}.firebaseio.com/");
  var events = $firebaseArray(firebaseEvents);

  $scope.newEvent = {
    title: '',
    start: ''
  };

  $scope.addEvent = function(){
    events.$add($scope.newEvent);

    $scope.newEvent = {
      title: '',
      start: ''
    };
  }

I'm fairly certain this will work as well