diff --git a/README.md b/README.md
index fb3f163..6ac3f28 100644
--- a/README.md
+++ b/README.md
@@ -31,12 +31,8 @@ Let's just have a look at the following example:
-
- Field is required
-
-
- Min length is 5
-
+ Field is required
+ Min length is 5
Field must contain at least one uppercase, one lowercase, and one number
@@ -61,14 +57,10 @@ You decide how to display the messages by defining your own Error component:
-
- {{ error.message }}
-
+ {{ error.message }}
-
- {{ constructDisplayedErrorMMessage(error) }}
-
+ {{ constructDisplayedErrorMMessage(error) }}
```
And the messages are centralized in a service:
diff --git a/demo-app/package-lock.json b/demo-app/package-lock.json
index e799ddb..5af47a4 100644
--- a/demo-app/package-lock.json
+++ b/demo-app/package-lock.json
@@ -156,9 +156,9 @@
}
},
"@angular/animations": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/animations/-/animations-7.2.0.tgz",
- "integrity": "sha512-xi832o3YN+eYSV4PDRllc8JwkH4aKPlb7NZ0UaqchOmz9/jQcykCEMZDzQAZUgHG1ohay6JBVaV8/zNcbSsRCA==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/animations/-/animations-7.2.1.tgz",
+ "integrity": "sha512-2AHc4HYz2cUVW3E0oYOTyUzBTnPJdtmVOx/Uo6+jnRqikvOGFOc5VXzFIYODe1Iiy+EYcSZ1lvQqwUbpZd6gwA==",
"requires": {
"tslib": "^1.9.0"
}
@@ -190,25 +190,25 @@
}
},
"@angular/common": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/common/-/common-7.2.0.tgz",
- "integrity": "sha512-5HNGT+XsY+7sQcNoFRqhbUfVdnBAtXaupmMbBclnQHTon9y9Ijp0ocYi7zxx39feo6xYF5HhBMnDPkFgtAnsYQ==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/common/-/common-7.2.1.tgz",
+ "integrity": "sha512-lYf3MeVMz69EriS5ANFY5PerJK0i4xHp/Jy67reb8ydZ+sfW320PUMuFtx3bZvk9PD7NdL3QZvXmla/ogrltTQ==",
"requires": {
"tslib": "^1.9.0"
}
},
"@angular/compiler": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-7.2.0.tgz",
- "integrity": "sha512-On1qj4yQoIGxGOQ09ohTq0QNjrIJtWcwnCXYAEEyc83eadBMOqiFh6SUMgX1O+B7BIB4mebFw/n/etez0A21xw==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-7.2.1.tgz",
+ "integrity": "sha512-wf9w882hNoRaTDRqkEvQxV7nGB3liTX/LWEMunmm/Yz0nWkvgErR9pIHv3Sm4Ox0hyG3GdMpcVBzQ8qPomGOag==",
"requires": {
"tslib": "^1.9.0"
}
},
"@angular/compiler-cli": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-7.2.0.tgz",
- "integrity": "sha512-BKELLAnA4jWfyPEzuVxTNNFAPKJOyh4Xjw7c+dRf90bnw9iIgZOpz9WXSN/xfEhftqRPTnPcfs56i6bxqeYCCQ==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-7.2.1.tgz",
+ "integrity": "sha512-ImmKTnBbAWIY7qrYSPFLJE83VYcDX7zK6Ig/vOl4e6dzvpZfJDYHMT8ELeWj7a2nkL9SjT8X3o9Mkbrb75Tepg==",
"dev": true,
"requires": {
"canonical-path": "1.0.0",
@@ -543,25 +543,25 @@
}
},
"@angular/core": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/core/-/core-7.2.0.tgz",
- "integrity": "sha512-tlCDDM9IknXvVLk1sg0lzCO4OREM54i1bFtTpl5kPtugK6l4kYCOH78UzDPHnOzzI3LGLj8Hb2NiObVa9c4fdg==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/core/-/core-7.2.1.tgz",
+ "integrity": "sha512-FYNAf4chxBoIVGCW2+fwR2MB2Ur5v1aG9L6zCcMXlZLbR64bu5j2m4e70RhXk/VptKvYWJ45od3xE5KfcaeEig==",
"requires": {
"tslib": "^1.9.0"
}
},
"@angular/forms": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-7.2.0.tgz",
- "integrity": "sha512-vgnKgThitbaSQekTFt8qCFejnBwBMNJDUm7LJFcvRn4wcZKArTARTfSKHudNYCjTEqs9/YT4TJQTm9flVRbUJw==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-7.2.1.tgz",
+ "integrity": "sha512-MxinNUvl02UfpY9gJtbTU6Mdt9fjIJYOGskcpwm+5u9jiMeRvOnG94ySoNrygg3EWwScX+P0mM4KN6fJWau7gQ==",
"requires": {
"tslib": "^1.9.0"
}
},
"@angular/language-service": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/language-service/-/language-service-7.2.0.tgz",
- "integrity": "sha512-UDmIRR0ybdafrJLHkSDgc/3PpsA9lnwXqGMSAyyhEF3InORFFkloAb0a6Naz+y8ePgEMfqbpyWjtzo8qGtOmEQ==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/language-service/-/language-service-7.2.1.tgz",
+ "integrity": "sha512-LmeoO7KXBcPRDvQpBv+ttG9oalCE0z7+AxbJBJNrrwzypP624B3xX2XWai9XUNkxu+shqE00lAU2lC7Fxs5v7A==",
"dev": true
},
"@angular/material": {
@@ -573,25 +573,25 @@
}
},
"@angular/platform-browser": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-7.2.0.tgz",
- "integrity": "sha512-ClrGYlacK0kexE7eHLfruOjgJl0MtMt7RsMv5i757GUwbOm1dCwG1HK8cLNDZJFHMZodKVKwEGS6/R5Cl6vrNg==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-7.2.1.tgz",
+ "integrity": "sha512-/6uHdFLmRkrkeOo+TzScrLG2YydG8kBNyT6ZpSOBf+bmB5DHyIGd55gh/tQJteKrnyadxRhqWCLBTYAbVX9Pnw==",
"requires": {
"tslib": "^1.9.0"
}
},
"@angular/platform-browser-dynamic": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-7.2.0.tgz",
- "integrity": "sha512-IiyBcQIQVDZMxfpTYex1QfPmcMubKLgu1pCvQsjr0HmUEySqcykO+FzHlYLf5TTgRrtkI6cP2pYzTHGVR93Gpg==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-7.2.1.tgz",
+ "integrity": "sha512-hrSkI7aESEkqYnu628Z/LvYNlUNMqIqkXYAkT3urxFdCw7UwNeZKrDmd9sRwK3gK3sC1VeD9pXtqaKmGsnBjOA==",
"requires": {
"tslib": "^1.9.0"
}
},
"@angular/router": {
- "version": "7.2.0",
- "resolved": "https://registry.npmjs.org/@angular/router/-/router-7.2.0.tgz",
- "integrity": "sha512-Jpm0Y5IH30hIQsbnLgi2/LgHbArfE9gWMj/9mDIUOlJeQfGzNVoifBE+zLLJU/wb09+ZtfwGBxkMeDTitH/n2A==",
+ "version": "7.2.1",
+ "resolved": "https://registry.npmjs.org/@angular/router/-/router-7.2.1.tgz",
+ "integrity": "sha512-3qMZnhFr6xx3dMy14rKwIw9ISTOZlsp9jAkthXVsfA2/thffScXHPBrH4SipkySLmOAtPmF5m5jscy8mx/1mJQ==",
"requires": {
"tslib": "^1.9.0"
}
diff --git a/demo-app/src/app/app-routing.module.ts b/demo-app/src/app/app-routing.module.ts
index 35e6adf..1e8a3b3 100644
--- a/demo-app/src/app/app-routing.module.ts
+++ b/demo-app/src/app/app-routing.module.ts
@@ -1,13 +1,14 @@
+/*tslint:disable:completed-docs */
import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
-//import {AppComponent} from "./app.component";
import { ReactiveFormsExampleComponent } from "./pages/reactive-forms-example/reactive-forms-example.component";
import { NgxFormsExampleComponent } from "./pages/ngx-forms-example/ngx-forms-example.component";
+import { TemplateDrivenFormsExampleComponent } from "./pages/template-driven-forms-example/template-driven-forms-example.component";
const routes: Routes = [
- //{ path: "", component: AppComponent},
- { path: "", redirectTo: "/reactive-forms", pathMatch: "full" },
+ { path: "", redirectTo: "/template-driven-forms", pathMatch: "full" },
{ path: "reactive-forms", component: ReactiveFormsExampleComponent },
+ { path: "template-driven-forms", component: TemplateDrivenFormsExampleComponent },
{ path: "ngx-form-errors", component: NgxFormsExampleComponent }
];
diff --git a/demo-app/src/app/app.component.html b/demo-app/src/app/app.component.html
index 8d37d70..7fa1d30 100644
--- a/demo-app/src/app/app.component.html
+++ b/demo-app/src/app/app.component.html
@@ -1,10 +1,13 @@
Ngx-Form-Errors Validation messages in Reactive Forms made easy
+
+
-
+
+ Template Driven Forms
Reactive Forms
Ngx Form Errors
diff --git a/demo-app/src/app/app.component.scss b/demo-app/src/app/app.component.scss
index 11610e0..8a95ffe 100644
--- a/demo-app/src/app/app.component.scss
+++ b/demo-app/src/app/app.component.scss
@@ -1,3 +1,4 @@
+/*
.form-group {
display: flex;
align-items: start;
@@ -49,3 +50,4 @@
border: 1px #000 solid;
border-radius: 6px;
}
+*/
diff --git a/demo-app/src/app/app.component.ts b/demo-app/src/app/app.component.ts
index 639255e..900bb8b 100644
--- a/demo-app/src/app/app.component.ts
+++ b/demo-app/src/app/app.component.ts
@@ -7,7 +7,11 @@ import { Component, OnInit } from "@angular/core";
styleUrls: ["./app.component.scss"]
})
export class AppComponent implements OnInit {
- public constructor() {}
+ public constructor() {
+ /*empty*/
+ }
- public ngOnInit(): void {}
+ public ngOnInit(): void {
+ /*empty*/
+ }
}
diff --git a/demo-app/src/app/app.module.ts b/demo-app/src/app/app.module.ts
index d908afb..45600dc 100644
--- a/demo-app/src/app/app.module.ts
+++ b/demo-app/src/app/app.module.ts
@@ -17,6 +17,7 @@ import { LanguageSelectorComponent, SimpleFormErrorComponent, TranslatedFormErro
import { AppRoutingModule } from "./app-routing.module";
import { ReactiveFormsExampleComponent } from "./pages/reactive-forms-example/reactive-forms-example.component";
import { NgxFormsExampleComponent } from "./pages/ngx-forms-example/ngx-forms-example.component";
+import { TemplateDrivenFormsExampleComponent } from "./pages/template-driven-forms-example/template-driven-forms-example.component";
/* tslint:disable:no-hardcoded-credentials */
@NgModule({
@@ -26,7 +27,8 @@ import { NgxFormsExampleComponent } from "./pages/ngx-forms-example/ngx-forms-ex
SimpleFormErrorComponent,
TranslatedFormErrorComponent,
ReactiveFormsExampleComponent,
- NgxFormsExampleComponent
+ NgxFormsExampleComponent,
+ TemplateDrivenFormsExampleComponent
],
imports: [
BrowserModule,
diff --git a/demo-app/src/app/components/translated-form-error/translated-form-error.component.html b/demo-app/src/app/components/translated-form-error/translated-form-error.component.html
index cd24e08..00c3999 100644
--- a/demo-app/src/app/components/translated-form-error/translated-form-error.component.html
+++ b/demo-app/src/app/components/translated-form-error/translated-form-error.component.html
@@ -1 +1 @@
- {{ error.message | translate: error.params }}
+ {{ error.message | translate: error.params }}
diff --git a/demo-app/src/app/components/translated-form-error/translated-form-error.component.ts b/demo-app/src/app/components/translated-form-error/translated-form-error.component.ts
index 5b57b45..2574e6e 100644
--- a/demo-app/src/app/components/translated-form-error/translated-form-error.component.ts
+++ b/demo-app/src/app/components/translated-form-error/translated-form-error.component.ts
@@ -25,19 +25,18 @@ export class TranslatedFormErrorComponent implements NgxFormErrorComponent, OnIn
public checkForErrors(): void {
this.errors$.subscribe((errors: NgxFormFieldError[]) => {
- // the formField can be retrieved from the "fieldName" param of any of the errors
+ this.errors = errors;
+
if (errors.length) {
+ // the formField can be retrieved from the "fieldName" param of any of the errors
this.fieldName = errors[0].params.fieldName;
+ this.translateFieldName();
}
-
- this.errors = errors;
- this.translateFieldName();
});
}
public translateFieldName(): void {
for (const error of this.errors) {
- console.log("-------- translating error.params.fieldName", this.fieldName);
error.params = { ...error.params, fieldName: this.translateService.instant(this.fieldName) };
}
}
diff --git a/demo-app/src/app/pages/ngx-forms-example/ngx-forms-example.component.html b/demo-app/src/app/pages/ngx-forms-example/ngx-forms-example.component.html
index 3b810f1..d69acbf 100644
--- a/demo-app/src/app/pages/ngx-forms-example/ngx-forms-example.component.html
+++ b/demo-app/src/app/pages/ngx-forms-example/ngx-forms-example.component.html
@@ -31,43 +31,63 @@
Submit
Get Form status
+
+ {{ showValidationDetails ? "Hide validation details" : "Show validation details" }}
+
+
+ {{ showValidationSummary ? "Hide validation summary" : "Show validation summary" }}
+
-