Trying to use ng-model in services file

I am trying to use the value for my ng-model mileages.mpg but when I actually use my function the value is being logged as undefined. I don't think I am doing anything wrong as I have been able to use this method before. I don't understand why it is not working. Is there something I am doing wrong and just not seeing. Any help would be greatly appreciated. I am trying to implement this in my add function.

So after continual effort I have everything working except for the adding of the mpg value I am calculating it visibly but I can not access it. Could this be because I am not physically typing the value in as an input? Just need some sort of idea for a fix.

tab-calculations.html

    <ion-view view-title="Calculations">
  <ion-content class="padding">
  <form oninput="x.value=parseInt(a.value)/parseInt(b.value)" ng-model="mileage.mpg">
    <input type="number" id="a" placeholder="Enter Miles Driven" ng-model="mileage.miles_driven">
    /<input type="number" id="b" placeholder="Enter gallons added" ng-model="mileage.gallons_added">
    =<input type="number" name="x" for="a b" placeholder="Mileage">
  </form>
  <input class="input" ng-model="mileage.car" placeholder="Enter Car model and year"> 
  <ion-button class="button" ng-click="add(mileage)">Add</ion-button>
  </ion-content>
</ion-view>

services.js

    angular.module('gas-mileage-tracker.services', [])

.factory('Mileages', function() {
    var mileages = [{
    id: 0,
    mpg: "17",
    car: "1998 Toyota 4runner",
    miles_driven: "",
    gallons_added: ""
  }, {
    id: 1,
    mpg: 16,
    car: "2002 Toyota 4runner",
    miles_driven: "",
    gallons_added: ""
  }, {
    id: 2,
    mpg: 18,
    car: "2002 Toyota 4runner",
    miles_driven: "",
    gallons_added: ""
  }, {
    id: 3,
    mpg: 17,
    car: "1998 Toyota 4runner",
    miles_driven: "",
    gallons_added: ""
  }, {
    id: 4,
    mpg: 18,
    car: "2002 Toyota 4runner",
    miles_driven: "",
    gallons_added: ""
  }];

  return {
    all: function() {
      return mileages;
    },
    remove: function(mileage) {
      mileages.splice(mileages.indexOf(mileage), 1);
    },
    add: function(mileage) {
      mileages.id = mileages.length;
      mileages.push({
        editMode: false,
        id: mileages.id,
        mpg: mileage.mpg,
        car: mileage.car
      });
      console.log(mileage.m);
      mileage.mpg= '';
      mileage.miles_driven= '';
      mileage.gallons_added= '';
      mileage.car= '';
    },
    edit: function(mpg) {
      mileage.editMode = true;
      mileages.mpg = mileage.mpg
      console.log(mileage);
    },
    save: function(mpg) {

        mileage.editMode = false;
    },
    get: function(mileageId) {
      for (var i = 0; i < mileages.length; i++) {
        if (mileages[i].id === parseInt(mileageId)) {
          return mileages[i];
        }
      }
      return null;
    }
  };
});

controllers.js

angular.module('gas-mileage-tracker.controllers', [])

.controller('CalculationsCtrl', function($scope, Mileages) {
    $scope.add = function(mileage) {
        Mileages.add(mileage);
    }
})
.controller('MileagesCtrl', function($scope, Mileages) {
    $scope.mileages = Mileages.all();
    $scope.remove = function(mileage) {
        Mileages.remove(mileage);
    };
    $scope.add = function(mileage) {
        Mileages.add(mileage);
    };

})
.controller('MileageDetailsCtrl', function($scope, $stateParams, Mileages) {
    $scope.mileage = Mileages.get($stateParams.mileageId);
})

in your console.log, mileages is an array, so it doesn't know the property .mpg. I think you want mpg.mpg, also, you're trying to set the id on the array instead of on the mpg object.

In your edit and save function you are also referring to an unknown object mileage, which (probably) should be mpg (same as the function parameter)