Skip to content

Commit

Permalink
feat(ngx-formcontrol-errors-msgs): allow HTML tags in error messages (#…
Browse files Browse the repository at this point in the history
…15)

* feat(ngx-formcontrol-errors-msgs): allow HTML tags in messages

* docs: update readme
  • Loading branch information
dgonzalez870 authored Mar 18, 2024
1 parent 0128905 commit ffa65fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const appConfig: ApplicationConfig = {
provide: FORM_ERROR_MESSAGES_PROVIDER,
useValue: {
// This message will override the default message
required: "This is a required field",
required: "This is a <b>required</b> field",
// This is a message for a custom validator and will extend the default
// messages
myCustomValidation: "There is an error",
Expand All @@ -101,6 +101,8 @@ export const appConfig: ApplicationConfig = {
};
```

HTML tags are allowed.

## Internationalization (I18N)

### 1. Angular I18N
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import {
Component,
ElementRef,
Input,
} from '@angular/core';

@Component({
selector: 'ngx-formcontrol-errors',
standalone: true,
template: `{{ message }}`,
template: ``,
})
export class NgxFormcontrolErrorsComponent {
@Input()
message = '';
set message(msg: string) {
this.elementRef.nativeElement.innerHTML = msg;
}

constructor(private readonly elementRef: ElementRef<HTMLElement>) {}
}

0 comments on commit ffa65fb

Please sign in to comment.