Module: FormAngular::Errors::NgError

Includes:
NgOptionUtils
Defined in:
lib/form_angular/errors/ng_error.rb

Instance Method Summary collapse

Instance Method Details

#has_html_errorObject



19
20
21
# File 'lib/form_angular/errors/ng_error.rb', line 19

def has_html_error
  ng_error.present?
end

#html_options(key) ⇒ Object



23
24
25
26
# File 'lib/form_angular/errors/ng_error.rb', line 23

def html_options(key)
  html_options ||= {}
  html_options.merge!({'ng-show' => "#{ng_access_expression}.$error.#{key} && (#{ng_access_expression}.$invalid || #{ng_access_expression}.$dirty)", class: "ng-cloak text-danger"})
end

#ng_error(wrapper_options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/form_angular/errors/ng_error.rb', line 8

def ng_error(wrapper_options)
  error_tags = ""
  error_tags = template.(:span, "{{errors['#{tag_name}'].server}}", html_options("server"))
  if @options[:ng_errors]
    @options[:ng_errors].each do |validate_key|
      error_tags += template.(:span, I18n.t("activerecord.errors.#{lookup_model_names.last}.#{attribute_name}.#{validate_key}"), html_options(validate_key))
    end
  end
  error_tags
end