Skip to content

Commit

Permalink
Merge pull request #271 from zvaraondrej/using-model-value
Browse files Browse the repository at this point in the history
Using model value
  • Loading branch information
Huei Tan authored Jan 20, 2017
2 parents aa13b20 + c538ea9 commit 73a8fae
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dist/angular-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ angular.module('validation.directive', ['validation.provider']);
/**
* All attributes
*/
var useViewValue = attrs.useViewValue !== 'false';
var validator = attrs.validator;
var messageId = attrs.messageId;
var validationGroup = attrs.validationGroup;
Expand Down Expand Up @@ -746,7 +747,7 @@ angular.module('validation.directive', ['validation.provider']);
* Click submit form, check the validity when submit
*/
scope.$on(ctrl.$name + 'submit-' + uid, function(event, index) {
var value = ctrl.$viewValue;
var value = useViewValue ? ctrl.$viewValue : ctrl.$modelValue;
var isValid = false;

isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validation.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/validator.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
/**
* All attributes
*/
var useViewValue = attrs.useViewValue !== 'false';
var validator = attrs.validator;
var messageId = attrs.messageId;
var validationGroup = attrs.validationGroup;
Expand Down Expand Up @@ -368,7 +369,7 @@
* Click submit form, check the validity when submit
*/
scope.$on(ctrl.$name + 'submit-' + uid, function(event, index) {
var value = ctrl.$viewValue;
var value = useViewValue ? ctrl.$viewValue : ctrl.$modelValue;
var isValid = false;

isValid = checkValidation(scope, element, attrs, ctrl, validation, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* jasmine specs for provider go here */

describe('provider', function() {
describe('provider without use-view-value', function() {
var $rootScope;
var $compile;
var $scope;
Expand Down
Loading

0 comments on commit 73a8fae

Please sign in to comment.