Skip to content

Instantly share code, notes, and snippets.

@dimaShin
Created March 18, 2016 13:31
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 dimaShin/8b2994c6fa4ce35f94a5 to your computer and use it in GitHub Desktop.
Save dimaShin/8b2994c6fa4ce35f94a5 to your computer and use it in GitHub Desktop.
ngFormController decorator
;(function (ng) {
FormControllerDecorator.$inject = ['$delegate', 'Helpers'];
function FormControllerDecorator ($delegate, helpers) {
const ngForm = $delegate[0];
const FormController = ngForm.controller;
FormController.prototype._errorMessages = helpers.errorMessages;
FormController.prototype._showError = modelController => {
if (modelController.$valid) {
return false;
}
return modelController.$dirty || modelController.$touched;
};
return $delegate;
}
ng.module('investum').decorator('ngFormDirective', FormControllerDecorator);
}(window.angular));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment