Created
February 26, 2018 20:20
-
-
Save timmyomahony/238bd54d31d3983809440b7b3ffae7cb to your computer and use it in GitHub Desktop.
Example Angular form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.submitForm = function(isValid) { | |
if ($scope.userForm.$valid) { | |
alert('Thank you for registering'); | |
location.reload(); | |
} else { | |
alert('Error registering'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate> | |
<div class="form-group"> | |
<label>Name</label> | |
<input type="text" id="name" name="name" ng-model="name" class="form-control" required> | |
<p ng-show="userForm.name.$invalid" class="help-block">Your name is required.</p> | |
</div> | |
<div class="form-group"> | |
<label for="email">Email</label> | |
<input type="email" id="email" name="email" ng-model="email" class="form-control" required> | |
<p ng-show="userForm.email.$invalid" class="help-block">Your email is required.</p> | |
</div> | |
<input type="submit" class="btn btn-primary" value="Submit" ng-disabled="userForm.$invalid"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment