I'm creating an app that use some angular-ui directives for example the ui-map directive and also its dependency ui-event the thing is that I want to create routes for diferent controllers that have some functinalities in common for example the acces to the gmap events. To achive that I've used the ng-View native directive of angular but the problem is that this directive creates a new scope so I don't have access to the previews scope. Maybe you could understand me better if you read the code.
angular.module('Maptesting', ['ngRoute', 'ui.map', 'ui.event'])
.config (function ($routeProvider) {
$routeProvider
.when('/', {
})
.when('/newSector', {
templateUrl: 'newSector.html',
controller: 'newSector'
})
})
.controller('CtrlGMap', ['$scope', function($scope) {
$scope.mapOptions = {
center: new google.maps.LatLng(-54.798112, -68.303375),
zoom: 11,
mapTypeId: google.maps.MapTypeId.SATELLITE,
disableDefaultUI: true
};
}])
.controller('newMarker', ['$scope', function($scope){
$scope.myMarker = null;
$scope.addMarker = function ($event, $params) {
$scope.myMarker = new google.maps.Marker({
map: $scope.myMap,
position: $params[0].latLng,
})
};
}])
HTML:
<body ng-controller="CtrlGMap" id="map">
<div id="map_canvas" class="map-canvas" ui-map="myMap"
ui-event="{'map-click': 'addMarker($event, $params)'}"
ui-options="mapOptions"></div>
<div ui-map-info-window="myInfoWindow">
<p>{{ name || "Set the name"}}</p>
</div>
<div ui-map-marker="myMarker"
ui-event="{'map-click': 'openMarkerInfo(myMarker)'}">
</div>
<div ng-view></div>
How can I have access to the parent scope?