I'm using the NgMap library to use the google maps api in my angular app.
I'm adding markers using an ng-repeat directive, each with an on-click tag that calls to the controller and logs to the console.
<ng-map zoom="11" center="[40.74, -74.18]">
<marker ng-repeat="p in vm.positions"
position="{{p.pos}}"
on-click="vm.showData(p)" //this is my on-click event, passing through the ng-repeated object
title="pos: {{p.pos}}"></marker>
</ng-map>
For some reason, every time I pass a parameter to my controller function it's actually the marker object being passed through, not the argument I'm passing from the view.
vm.showData = function (marker, param){
console.log(marker) //WHY IS MARKER BEING PASSED THROUGH?!
console.log(param.name); //THE SECOND ARGUMENT IS THE ONE I WANT, WHY ISN'T IT THE FIRST?
}
Eventually after banging my head against the wall, I decided to check if any other arguments were being passed through to the controller function. Low and behold the second argument was the one I expected to be passed through to begin with.
Why isn't the first argument the one I'm expecting?! Is it something to do with the ngMap library, angular, or just a javascript nuance I'm unaware of?
A working plunker can be found here: https://embed.plnkr.co/TQpm4O/