0

Some time post request takes query string i.e localhost/?password=123456 Don't know why do we need to add button type="button" or type="submit" please suggest thanks

<form name="login" novalidate>
   <div class="row">
      <input type="text" required name="email" id="username" ng-model="email" class="with-border" autofocus=true auto-focus>
   </div>
   <div>
      <input type="password" required name="password" id="password" ng-model="password" class="with-border" >
   </div>
   <a class="pull-left recover-password f-pass-valign" href="#!/forgotpassword">Forgot password?</a>
   <div class="form-group">
      <button ng-click="login(user.email, password)" type="button" class="btn btn-danger">Login</button>               
   </div>
</form>
5
  • Instead of calling login(...) on ng-click, call it on ng-submit on the form. Commented May 16, 2019 at 5:48
  • Anything else that need to replace rather than ng-click to ng-submit ?? Commented May 16, 2019 at 5:52
  • Try setting method="post" on the form tag. Commented May 16, 2019 at 5:54
  • I am confused which one is opt should i use ng-submit into form or use post as method please guide @31piy Commented May 16, 2019 at 6:10
  • @Jacob check out this w3schools.com/angular/tryit.asp?filename=try_ng_ng-submit Commented May 16, 2019 at 9:02

1 Answer 1

1
<form name="login" novalidate method="post">
            <div class="row">
                <input type="text" required name="email" id="username" ng-model="email" class="with-border" autofocus=true auto-focus>
            </div>
            <div>
                <input type="password" required name="password" id="password" ng-model="password" class="with-border" >
            </div> 
            <a class="pull-left recover-password f-pass-valign" href="#!/forgotpassword">Forgot password?</a>
            <div class="form-group">
              <button ng-click="login(user.email, password)" class="btn btn-danger">Login</button>               
            </div>

        </form>

use method as post if you setup button type button then it will work on button click only

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.