aravindtrue aravindtrue - 16 days ago 6
Javascript Question

Ionic Framework - Buttons inside form labels

I have a form like below,

<form>
<div class="list">
<label class="item item-input item-stacked-label">
<span class="input-label">First Name</span>
<input type="text">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Last Name</span>
<input type="text">
</label>
<label class="item item-button-right">
Photo
<button style="right: 95px;" class="button button-small button-clear" ng-click="get_gallery();">
Gallery
</button>
<button class="button button-small button-clear" ng-click="get_camera();">
Camera
</button>
</label>
</div>
</form>


The Problem is that whatever the button I hit, it always triggers
get_gallery()
method and never calls
get_camera()
. Can you someone help me what is the problem? I have also tried in other way which will look like,

<label class="item item-input item-stacked-label">
Receipt
<div>
<button class="button button-small button-clear" ng-click="get_gallery();">
Gallery
</button>
<button class="button button-small button-clear" ng-click="get_camera();">
Camera
</button>
</div>
</label>


Am I doing something wrong? What is the proper way to do it?

Answer

Change label tag to div, that will help.