I am facing an issue with two buttons that have the same ng-click but different parameters.
<label class="item item-input">
<button ng-click="takePicture(true)">Save Settings</button>
<button ng-click="takePicture(false)">Choose from Gallery</button>
</label>
Despite my efforts, both buttons end up passing the same parameter as the first function call.
Even with a simple controller function for testing purposes, the same parameter is logged. In this instance, it always logs true
.
$scope.takePicture = function(my_param) {
console.log(my_param);
}
This issue seems to be specific to Ionic framework and does not occur with standard Angular. A CodePen example demonstrating the problem can be found here:
http://codepen.io/anon/pen/JYBKVQ
Edit: As suggested in the solution below, the source of the problem lies within the code excerpt above. The culprit appears to be the <label>
element. Beware!