1
<input type="text" name="input" ng-model="email" placeholder="Email ID"/>
<!--input text box which value is send when click event fire.-->
<button type="submit" id="Button1" ng-click="sendBtnForgotPswd(email)" />
</form>

I don't want to fire click event when input "email" is undefined. Any in built filter provide by AngularJS for prevent click event*

br.julien
  • 3,420
  • 2
  • 23
  • 44
chirag
  • 1,818
  • 1
  • 15
  • 36
  • possible duplicate of [Disable submit button when form invalid with AngularJS](http://stackoverflow.com/questions/15300067/disable-submit-button-when-form-invalid-with-angularjs) – dnozay Nov 14 '14 at 07:01

2 Answers2

2

You have at least two possibilities here. Probably optimal one is to use ngDisabled directive to deactivate button when email is empty:

<button ng-disabled="!email" ng-click="sendBtnForgotPswd(email)" 
        type="submit" id="Button1" >Send</button>

Other option is to call sendBtnForgotPswd function only when email is filled in:

<button type="submit" id="Button1" ng-click="email && sendBtnForgotPswd(email)">Send</button>

Also note that button tag cannot be self-closable so you should add closing </button>.

dfsq
  • 191,768
  • 25
  • 236
  • 258
1

Use ng-disabled="!email" on the button element.

psp
  • 3,294
  • 1
  • 19
  • 17