AngularJS Simple Example
by Khajan Singh
HTML
<div ng-app ng-controller="LoginController" novalidate>
<form name="login">
<p>
<label for="email">Email</label>
<span> <input type="text" value="" ng-model="reg.email" size="40" id="email"
name="reg_email">
</span>
<span ng-show="login.reg_email.$error.required"><p ng-show="errorMsgShow" class="red">{{requiredMsg}}</p></span>
<span ng-show="login.reg_email.$invalid"><p ng-show="errorMsgShow" class="red">{{invalidEmailMsg}}</p></span>
</p>
<button ng-click="validation()" >submit</button>
</form>
</div>
CSS
.red{
color:#f20;
}
JavaScript
function LoginController($scope) {
$scope.validation = function(){
$scope.requiredMsg="This question is required";
$scope.invalidEmailMsg = "invalid Email";
$scope.errorMsgShow = true;
}
}