title: firebase - Use one ref for an object and push onto it's child array
body: <p>This code works however I'm using two refs to access different areas of the same object.</p>
  
  <p>A routine may have multiple pages.  Is there a way to create new pages and just use one ref to push pages onto $scope.routine.pages that also create a unique id?</p>
  
  <p><img src="https://i.stack.imgur.com/qoQAM.png" alt="enter image description here"></p>
  
  <pre><code>angular.module('screenTester.auth.routine', [
      'screenTester.auth.routine.page'    
  ])
  
  .config(['$stateProvider', function($stateProvider) {
  
      $stateProvider
          .state('auth.routine', {
              url: '/routine/:routineId',
              controller: 'RoutineCtrl',
              templateUrl: '/dist/auth/routine/routine.html'
          });
  
  }])
  
  .controller('RoutineCtrl', ['$scope', '$stateParams', '$firebase', function($scope, $stateParams, $firebase) {
  
      $scope.routineId = $stateParams.routineId;
  
      // Combine these two and still create pages with a unique id?
      var ref = new Firebase("https://url.firebaseio.com/user" + $scope.auth.user.id + '/routines/' + $scope.routineId);
      var sync = $firebase(ref);
  
      var ref = new Firebase("https://url.firebaseio.com/user" + $scope.auth.user.id + '/routines/' + $scope.routineId + '/pages');
      var pagesSync = $firebase(ref);
  
      $scope.createPage = function() {
          // What method would I use here on `$scope.routine`?        
          $scope.routinePages.$add($scope.newPage);
          $scope.routinePages.$save();
          $scope.newPage = {};
          $scope.toggles.showCreatePage = false;
      };
  
      $scope.init = function() {
        $scope.routine = sync.$asObject();
        $scope.routinePages = pagesSync.$asArray();
  
        $scope.newPage = {};
        $scope.toggles = {};
      };
  
      $scope.init();
  
  }]);
  </code></pre>
  
  <p>Disclaimer: Not my final code I'm learning how firebase works to see if it's a good solution.</p>