Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-click inside label does not work

<ion-view>
	<div class="bar bar-header bar-dark">
		<h1 class="title">Welcome</h1>
	</div>
	<ion-content class="has-header">
		<form ng-submit="doLogin()">
			<div class="list">
				<label class="item item-input">
					<span class="input-label">手机号</span>
					<input type="text" ng-model="phonenumber" placeholder="这里输入手机号" maxlength="11">
					<button class="button button-dark" style="margin-right: 16px;" ng-click="getVerifyCode(111)">获取验证码</button>
				</label>
				<label class="item item-input">
					<span class="input-label">验证码</span>
					<input type="password" ng-model="verifycode">
				</label>
				<label class="item">
					<button class="button button-block button-dark" ng-click="getVerifyCode(111)">登 陆</button>
				</label>
			</div>
		</form>
	</ion-content>
</ion-view>
  1. why the button(获取验证码) inside label tag doesnt work?

  2. but the button(登 陆) outside label tag work fine, why?

  3. please help me to fixed this. I need to make a response when click the button(获取验证码)

like image 628
Chenzhao Wudics Avatar asked Nov 13 '15 06:11

Chenzhao Wudics


1 Answers

working demo

The solution is simply not to use a label for the item. Instead just use a div

html

<form ng-submit="doLogin()">
        <div class="list">
            <div class="item item-input">
                <span class="input-label">手机号</span>
                <input type="text" ng-model="phonenumber" placeholder="这里输入手机号" maxlength="11">
                <!-- <input ></input> -->
                <button class="button button-dark" style="margin-right: 16px;" ng-click="getVerifyCode(111)">获取验证码</button>
            </div>
            <label class="item item-input">
                <span class="input-label">验证码</span>
                <input type="password" ng-model="verifycode">
            </label>
            <label class="item">
                <button class="button button-block button-dark" ng-click="getVerifyCode(111)">登 陆</button>
            </label>
        </div>
</form>
like image 87
Muhsin Keloth Avatar answered Oct 17 '22 21:10

Muhsin Keloth