'use strict';

angular.module('velo-app').controller('MainCtrl', ['$scope', 'apiService', function ($scope, apiService) {
    $scope.initialize = function () {
        var map = L.mapbox.map('map', 'mapbox.streets');

        var apiRequest = new XMLHttpRequest();

        apiRequest.open('GET', '/api/cities/lyon/stations');

        apiRequest.addEventListener('load', function () {
            var stations = JSON.parse(this.response);

            var stationMarkers = [];

            stations.forEach(function (station) {
                var stationMarker = L.marker(L.latLng(station.position.lat, station.position.lng));

                stationMarkers.push(stationMarker);
            });

            var group = L.featureGroup(stationMarkers);
            group.addTo(map);
            
            map.fitBounds(group.getBounds());
        });

        apiRequest.send();
    };
    
    $scope.initialize();
}]);

@@ -223,223 +223,124 @@
     
-var apiRequest = new XMLHttpRequest();%0A%0A        apiRequest.open('GET', '/api/cities/lyon/stations');%0A%0A        apiRequest.addEventListener('load', function () %7B%0A            var stations = JSON.parse(this.response);%0A%0A
+apiService.getStations().then(%0A            function (response) %7B%0A                var stations = response.data;%0A%0A    
     
@@ -381,24 +381,28 @@
             
+    
 stations.for
@@ -423,24 +423,28 @@
 (station) %7B%0A
+    
             
@@ -544,24 +544,28 @@
             
+   
+ 
 stationMarke
@@ -592,32 +592,36 @@
 r);%0A            
+    
 %7D);%0A%0A           
@@ -617,24 +617,28 @@
             
+ 
+   
 var group = 
@@ -681,16 +681,20 @@
         
+  
+  
 group.ad
@@ -711,25 +711,33 @@
             
-%0A
+    %0A    
             
@@ -782,37 +782,158 @@
     
-%7D);%0A%0A        apiRequest.send(
+    %7D,%0A            function (error) %7B%0A                // TODO handle this error properly.%0A                console.error(error);%0A            %7D%0A        
 );%0A 

Use `$http` service to fetch stations data.