paulyoder / angular-bootstrap-show-errors

An Angular directive for Bootstrap to intelligently show form validation errors
MIT License
331 stars 77 forks source link

broadcast 'show-errors' event when toggling classes #34

Open jack-kerouac opened 9 years ago

jack-kerouac commented 9 years ago

This event can be listened on by directives inside the show-errors directive in order to e.g. show/hide a feedback icon or other error messages.

Example:

angular.module('app')
    .directive('feedbackIcon', function () {
        return {
            link: function (scope, elem) {
                scope.$on('show-errors', function (event, invalid) {
                    elem.toggleClass('glyphicon-remove', invalid);
                    elem.toggleClass('glyphicon-ok', !invalid);
                });
            }
        };
    });