我有两个按钮使用相同的ng-click和不同的参数.
<label class="item item-input"> <button ng-click="takePicture(true)">Save Settings</button> <button ng-click="takePicture(false)">Choose from Gallery</button> </label>
使用简单的控制器功能进行测试,记录相同的参数.在这种情况下,两者都是如此.
$scope.takePicture = function(my_param) { console.log(my_param); }
这些似乎只发生在Ionic中,而不是标准的Angular.这是一个工作示例的CodePen.
解决方法
将按钮嵌套在标签内是一个问题.如果您删除标签,它按预期工作:
http://codepen.io/anon/pen/ojMzLj
<div class="list list-inset"> <h3>Profile Picture</h3> <button class="button button-block button-calm" ng-click="takePicture(true)">Save Settings</button> <button class="button button-block button-calm" ng-click="takePicture(false)">Choose from Gallery</button> <label class="item item-input"> <input type="text" placeholder="Circle Color" ng-model="data.color"> </label> <label class="item item-input"> <input type="text" placeholder="Stroke Color" ng-model="data.stroke"> </label> </div>