angularjs and google maps - ng-click works in root but not in scope -
why in order getdirections called, has in $root ? ui-gmap below assigned controller via routes. here source:
angular.module('app').controller('mainctrl', function ($scope) { //this works $scope.$root.getdirections = function () {alert('here')}; //this should work! $scope.getdirections = function () {alert('here')}; }
html
<ui-gmap-google-map center='mapinfo.map.center' zoom='mapinfo.map.zoom'> <ui-gmap-marker coords="mapinfo.marker.coords" options="mapinfo.marker.options" idkey="mapinfo.marker.id"> <ui-gmap-window ng-cloak closeclick="closeclick()"> <ui-gmaps-window> <a ng-click="getdirections()" class="location" href="#">doesnt work</a> <a ng-click="$root.getdirections()" class="location" href="#">works</a> </ui-gmaps-window> </ui-gmap-window> </ui-gmap-marker> </ui-gmap-google-map>
Comments
Post a Comment