-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo.js
28 lines (24 loc) · 835 Bytes
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var app = angular.module('app', ['FormErrors']);
app.config(function (FormErrorsOptionsProvider) {
FormErrorsOptionsProvider.extendDefaultErrorMessages({
// It only overrides what you pass it. All
// other default messages will be left alone
form: 'has some errors. Please fix them.'
});
});
app.controller('MainCtrl', function ($scope) {
$scope.showErrors = false;
$scope.errorMessages = {
required: 'is very much required.',
minlength: 'is waaaaay too short.',
};
$scope.submit = function () {
if ($scope.loginForm.$valid) {
$scope.showErrors = false;
$scope.message = 'Form is valid!';
} else {
$scope.showErrors = true;
$scope.message = 'Please correct the above errors.';
}
};
});