Skip to content

Instantly share code, notes, and snippets.

@gmittica
Created October 23, 2017 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmittica/bef7345c13901490436181ca32cc2936 to your computer and use it in GitHub Desktop.
Save gmittica/bef7345c13901490436181ca32cc2936 to your computer and use it in GitHub Desktop.
Lesson // source http://jsbin.com/tebozuh
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Lesson</title>
<style id="jsbin-css">
.container {
margin-top:45px;
}
</style>
</head>
<body ng-app="myApp">
<div class="container" ng-controller="myCtrl">
<form name="myForm" class="form" ng-submit="sendForm()" novalidate >
<div class="form-group">
<input type="email" name="contact" ng-model-options="{ updateOn: 'blur'}" ng-model="form.contact" required="required" class="form-control" placeholder="Write here your email address" >
</div>
<div class="form-group">
<button type="submit" class="btn btn-info" >Save</button>
</div>
<div class="well" >
<span ng-show="myForm.contact.$touched && myForm.contact.$error.required">Email cannot be blank</span>
<span ng-show="myForm.contact.$touched && myForm.contact.$error.email">You must write a valid email address</span>
</div>
</form>
<div class="well">
{{ form | json }}
</div>
</div>
<script id="jsbin-javascript">
angular.module("myApp", [])
.controller("myCtrl", ['$scope', function($scope) {
$scope.form = {
}
$scope.sendForm = function() {
// do something with $scope.form
}
}]);
</script>
<script id="jsbin-source-css" type="text/css">.container {
margin-top:45px;
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">angular.module("myApp", [])
.controller("myCtrl", ['$scope', function($scope) {
$scope.form = {
}
$scope.sendForm = function() {
// do something with $scope.form
}
}]);</script></body>
</html>
.container {
margin-top:45px;
}
angular.module("myApp", [])
.controller("myCtrl", ['$scope', function($scope) {
$scope.form = {
}
$scope.sendForm = function() {
// do something with $scope.form
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment