angularjs rewrite controller without factory
<p>i'm developing an app that received from a server a JSON array and divided data in a specific way, i've a portion of code that works if i use it alone but if i tried to insert it in an application it doesn't work.</p>

<p>This is <strong>my code</strong>:</p>

<pre><code>ionicApp.controller('DefaultController', DefaultController)
  .factory('dataService', dataService);

DefaultController.$inject = ['dataService', '$http'];

function DefaultController(dataService, $http) {
  var vm = this;
  console.log("Dentro ctrl");
  getEvents();

  function getEvents() {
      console.log("Dentro getEvents");
    return dataService.getEvents()
      .then(function (data) {
          console.log("data: " + data);
        vm.data = data;
        console.log("vm.data: " + vm.data);
        return vm.data;
      });
  }
    vm.submit = function (){
        console.log("funzione");
        console.log(vm.form);
        var data = vm.form; // IMPORTANT
        //console.clear();
        var link = 'http://localhost/&lt;path&gt;/api/apiDoFix.php';
        var mail = window.localStorage.getItem("mail");
        var scelta = window.localStorage.getItem("scelta");
        console.log(data);
        console.log ("EMAIL" + mail);
        console.log ("SCELTA" + scelta);
        $http.post(link, {giorno: data.giorno, ora: data.ora, mail: mail, scelta: scelta})
            .then(function (res){
                console.log("Dentro http.post");
                var response = res.data;
                if (response != 'F'){
                    console.log("Dentro if");
                    console.log(response);
                    //window.location.href ="/#/main";
                } else {
                    console.log("Dentro else");
                }
            });
    };
}

dataService.$inject = ['$http'];

function dataService($http) {
    console.log("qua");
  var service = {
    getEvents: getEvents
  };

  return service;

  function getEvents() {
      console.log("qua2");
    var config = {
      transformResponse: function (data, headers) {
        var result = {
          events: [],
          schedules: []
        };
        var events = JSON.parse(data);
        var dates = [];
        console.log("qua3");
        for (var i = 0; i &lt; events.length; i++) {
          if (dates.indexOf(events[i].day) === -1) {
            var date = events[i].day;
            dates.push(date);
            result.events.push({
              date: date
            });
          }

          result.schedules.push({
            date: events[i].day,
            time: events[i].time
          });
        }
        console.log("result: " + result);
        return result;
      }
    };

    return $http.get('http://localhost/ShuttleFIX/api/apiTimes.php', config)
      .then(getEventsCompleted)
      .catch(getEventsFailed);
    function getEventsCompleted(response) {
        console.log("response " + response.data);
      return response.data;
    }

    function getEventsFailed(error) {
      console.error(error);
    }
  }
}
</code></pre>

<p>is it possible to rewrite this code in a controller function without using factory?</p>

<p>Thank's</p>