I'm trying to pass a javascript variable to a controller angular and I can not do it, any suggestions?
My function:
function coordenadas(position) {
            var latitud = position.coords.latitude;
            var longitud = position.coords.longitude;
        }
My controller:
'use strict';
/* Controllers */
var moduloMapa = angular.module('BeLiga.indexMapControllers', ['google-maps']);
moduloMapa.controller('controlIndexMap', function($scope) {
    obtener_localizacion();
    $scope.center = {
        latitude: 45,
        longitude: -73
    };
    $scope.zoom = 8;
});
I need to get the value of these two variables of function "coordenadas":
 var latitud;
 var longitud;


obtener_localizacion()? This function is being used, but is never defined in the code you've shown. Also, you must remember thatlatitudandlongitudare variables that exist only in the scope of thecoordenadasfunction.factory,service,constantandvalueconvenience functions on the angular module object.