0

View for the form part looks like

<md-dialog aria-label="Add Attendee">
  <form ng-cloak class="form-horizontal" name="attendeeForm" ng-submit="save(ctrl.attendee) && attendeeForm.$valid" novalidate>
    <md-toolbar>
      <div class="md-toolbar-tools">
        <h2>Enter Attendee</h2>
        <span flex></span>
        <md-button class="md-icon-button" ng-click="cancel()">
          <md-icon md-svg-src="img/icons/ic_close_24px.svg" aria-label="Close dialog"></md-icon>
        </md-button>
      </div>
    </md-toolbar>

    <md-dialog-content>
      <div class="md-dialog-content">
        <div class="form-group">
          <label for="firstName" class="control-label col-md-3 col-sm-4">First Name:</label>
          <div class="col-sm-8"><input type="text" class="form-control" id="firstName" placeholder="First Name" name="firstName" ng-model="ctrl.attendee.firstName" ng-required="true" /></div>
        </div>
        <div class="form-group">
          <label for="lastName" class="control-label col-md-3 col-sm-4">Last Name:</label>
          <div class="col-sm-8"><input type="text" class="form-control" id="lastName" placeholder="Last Name" name="lastName" ng-model="ctrl.attendee.lastName" ng-required="true" /></div>
        </div>
        <div class="form-group">
          <label for="email" class="control-label col-md-3 col-sm-4">Email:</label>
          <div class="col-sm-8"><input type="email" class="form-control" id="email" placeholder="Email Address" name="email" ng-model="ctrl.attendee.email" ng-required="true" /></div>
        </div>
      </div>
    </md-dialog-content>

    <md-dialog-actions layout="row">
      <span flex></span>
      <button class="btn btn-primary" type="submit">Save Attendee</button>
    </md-dialog-actions>
  </form>
</md-dialog>

When I submit that form without required fields the form is passing validation and can be submited. When I will remove novalidate it works fine which has no sense based on an answer from Angularjs prevent form submission when input validation fails which states No need for controller checks.

Any clue what is going on with it?

2
  • 1
    Change ng-submit to attendeeForm.$valid && save(ctrl.attendee) Commented Aug 15, 2017 at 20:59
  • @AlexK That did the job! I should to know that it can pass in my case save statement was before for became true Commented Aug 15, 2017 at 21:09

0

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.