How can i take information from one controller to another, or how can i make service from a controller? I need to take coordinates and save it to object with some other variables, if i put dependencie one controllers into another it doesnt work. Most of information in controller below are irrelevant, i just need lat and long, and save it in other controller.
.controller('MapCtrl', function($scope, $cordovaGeolocation, $ionicLoading, $ionicPlatform, $cordovaScreenshot, $ionicPopup) {
$ionicPlatform.ready(function() {
    $ionicLoading.show({
        template: '<ion-spinner icon="bubbles"></ion-spinner><br/>Acquiring location!'
    });
    var posOptions = {
        enableHighAccuracy: true,
        timeout: 20000,
        maximumAge: 0
    };
    $cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
        var lat  = position.coords.latitude;
        var long = position.coords.longitude;
        $scope.duzina = long;
        $scope.sirina = lat;
        console.log("Širina: " + lat + '\n' + "Dužina: " +  long);
        var myLatlng = new google.maps.LatLng(lat, long);
        var mapOptions = {
            center: myLatlng,
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };          
        var map = new google.maps.Map(document.getElementById("map"), mapOptions);          
        $scope.map = map;   
        $ionicLoading.hide();   
        var marker = new google.maps.Marker({
        animation: google.maps.Animation.DROP,
        draggable: true,
        label: 'A',
        position: myLatlng,
        map: map,
        title: 'Trenutna Lokacija'
    });
    var labels = 'BCDEFGHIJKLMNOPQRSTUVWXYZ';
    var labelIndex = 0;
    google.maps.event.addListener(map, 'click', function(event) {
    addMarker(event.latLng, map);
    });
    function addMarker(location, map) {
    var marker = new google.maps.Marker({
    position: location,
    label: labels[labelIndex++ % labels.length],
    map: map
    });   
    }       
    }, function(err) {
        $ionicLoading.hide();
        console.log(err);
    });
}) 
})
 
     
     
    