Skip to content

Commit 1108134

Browse files
authored
Merge pull request #11 from xtreamsrl/fix/angular8
Update to Angular 8
2 parents 467426d + 6e1f008 commit 1108134

26 files changed

Lines changed: 12323 additions & 7116 deletions

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
## 1.0.0 (2020-01-11)
2+
3+
### Features
4+
5+
* update to angular 8
6+
* add structural directive for controlled errors management
7+
8+
## Breaking Changes
9+
The 1.0.0 version is compatible with angular 8.
10+
11+
The components have been renamed according to the angular conventions, now they starts with the library prefix.
12+
Update this
13+
```angular2html
14+
<form [formGroup]="heroForm" validationContext="USER.REGISTRATION">
15+
<div formFieldContainer>
16+
<label>Name</label>
17+
<input formControlName="name"/>
18+
</div>
19+
</form>
20+
```
21+
changing the name to ngxValidationErrorsField
22+
23+
```angular2html
24+
<form [formGroup]="heroForm" validationContext="USER.REGISTRATION">
25+
<div ngxValidationErrorsField>
26+
<label>Name</label>
27+
<input formControlName="name"/>
28+
</div>
29+
</form>
30+
```
31+
32+
The old names are still available bu consider it deprecated!
33+
134
## 0.3.0 (2019-11-19)
235

336
## Breaking Changes

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ if the key is not present in the language file the message fallbacks to `${defau
2222

2323
## Usage
2424

25+
2526
Import it using
26-
```
27+
```typescript
2728
import {NgxValidationErrorsModule} from '@xtream/ngx-validation-errors';
2829

2930
@NgModule({
@@ -37,25 +38,52 @@ import {NgxValidationErrorsModule} from '@xtream/ngx-validation-errors';
3738
export class AppModule {
3839
}
3940
```
41+
### Components with auto errors injection
42+
now you can use validationContext and ngxValidationErrorsField in your template
4043

41-
now you can use validationContext and formFieldContainer in your template
42-
43-
```
44+
```angular2html
4445
<form [formGroup]="heroForm" validationContext="USER.REGISTRATION">
45-
<div formFieldContainer>
46+
<div ngxValidationErrorsField>
4647
<label>Name</label>
4748
<input formControlName="name"/>
4849
</div>
4950
</form>
5051
```
52+
or
53+
```angular2html
54+
<form [formGroup]="heroForm" validationContext="USER.REGISTRATION">
55+
<ngx-validation-errors-field>
56+
<label>Name</label>
57+
<input formControlName="name"/>
58+
</ngx-validation-errors-field>
59+
</form>
60+
```
5161

5262
According to the Validators set in the FormControl the errors appear when the input is invalid, dirty and touched.
5363

64+
### Structural directive
65+
66+
The structural directive has been created for special layout library (like material-ui) that have special input/errors
67+
components that do non allow to autoInject errors component. The usage is a little bit more verbose but the you control
68+
errors
69+
70+
```angular2html
71+
<form [formGroup]="heroForm" validationContext="USER.REGISTRATION">
72+
<mat-form-field *ngxValidationErrors="heroForm.get('name'); errors as errors">
73+
<input matInput formControlName="name" placeholder="name"/>
74+
<mat-error *ngIf="errors">{{errors}}</mat-error>
75+
</mat-form-field>
76+
</form>
77+
```
78+
79+
the structural directive needs the form control as parameter (like heroForm.get('name'), if you find a better way to retrieve the inner form control instance please open an issue).
80+
It exposes errors in the template context so you can use them in the ui.
81+
5482
### Clearing
5583

5684
The ValidationContextComponent has an imperative clear that resets all the fields removing all the errors.
5785

58-
```
86+
```typescript
5987
import {ValidationContextComponent} from '@xtream/ngx-validation-errors';
6088

6189

@@ -71,7 +99,7 @@ import {ValidationContextComponent} from '@xtream/ngx-validation-errors';
7199

72100
The library can be configured using the `forRoot` static method
73101

74-
```
102+
```typescript
75103
import {NgxValidationErrorsModule} from '@xtream/ngx-validation-errors';
76104

77105
@NgModule({

angular.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"src/assets"
2828
],
2929
"styles": [
30+
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
3031
"src/styles.scss"
3132
],
3233
"scripts": [],
@@ -84,6 +85,7 @@
8485
"tsConfig": "src/tsconfig.spec.json",
8586
"karmaConfig": "src/karma.conf.js",
8687
"styles": [
88+
"./node_modules/@angular/material/prebuilt-themes/pink-bluegrey.css",
8789
"src/styles.scss"
8890
],
8991
"scripts": [],
@@ -172,4 +174,4 @@
172174
}
173175
},
174176
"defaultProject": "ngx-validation-errors"
175-
}
177+
}

0 commit comments

Comments
 (0)