Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ng-click don´t work

I have this controller. It´s for a map view on the app Im working on. For some reason the button I have on the footer is not working. The action on the function is never called...

.controller('mapaCtrl', function($scope, $compile, $location) {

    $scope.goPayment = function() {
        $location.path('side-menu/history');
    };


var myLatlng = new google.maps.LatLng(34.603711, -58.381585);

    var mapOptions = {
        center: myLatlng,
        zoom: 16,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById("map"), mapOptions);

    navigator.geolocation.getCurrentPosition(function(pos) {
        map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
        var myLocation = new google.maps.Marker({
            position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
            map: map,
            title: "My Location"
        });

        google.maps.event.addListener(myLocation, 'click', function() {
            infowindow.open(map,myLocation);
        });
    });


    var contentString = "<div><a ng-click='clickTest()'>Pagar Aqui!</a></div>";
    var compiled = $compile(contentString)($scope);

    var infowindow = new google.maps.InfoWindow({
      content: compiled[0]
    });

  $scope.map = map;

      $scope.clickTest = function() {
    $location.path('side-menu/pay');
  };




})

And I have this call on the html

<ion-view title="Mapa" id="page13">
<ion-content ng-controller="mapaCtrl">
  <div id="map" data-tap-disabled="true"></div>
</ion-content>
<ion-footer-bar align-title="left" class="bar-balanced">
    <button class="button" ng-click="goPayment()">Ver mis pagos</button>

On the Button click there is no call to "$location.path('side-menu/history');"

Can you help me?

like image 510
Martin Ciappesoni Avatar asked Feb 28 '26 13:02

Martin Ciappesoni


1 Answers

Your button is outside the scope of the controller. Check your code.

<ion-view title="Mapa" id="page13">
<ion-content ng-controller="mapaCtrl">
  <div id="map" data-tap-disabled="true"></div>
</ion-content> <!--controller ends here-->

<ion-footer-bar align-title="left" class="bar-balanced">
    <button class="button" ng-click="goPayment()">Ver mis pagos</button>

The button is outside the controller so there's no function to be called.

like image 60
yBrodsky Avatar answered Mar 03 '26 01:03

yBrodsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!