angular.module("app").directive("formErrors", ['$compile', function ($compile) {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            errors: '=',
        },
        link: function (scope, element, attrs) {
            scope.$watchCollection('errors', function (newData, oldData) {
                if (angular.isArray(newData)) {
                    for (var index = 0; index < newData.length; index++) {
                        sqNotices.addNotice('error', newData[index]);
                    }
                }
            }, true);
        }
    };
}]);