Skip to content

Commit 2fb4b80

Browse files
committed
Update readme regarding polyfill, validation and route generator service
1 parent cc6439c commit 2fb4b80

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,56 @@ If you like to update the source do this
212212
```shell
213213
docker cp ./dist/. mycontainer:/usr/share/nginx/html
214214
```
215+
216+
## Additional features
217+
This repo houses some additional features which provd to be very useful in projects.
218+
219+
## String polyfill
220+
The file `utils/polyfills.utils.ts` contains a string polyfills.
221+
With this polyfill you can do this:
222+
```
223+
'Teststring'.isEmpty() => false
224+
''.isEmpty() => true
225+
undefined.isEmpty() => true
226+
```
227+
228+
## Validation
229+
The file `utils/validation.utils.ts` contains some validatoin helper functions and regex patterns.
230+
231+
The function `validateFilledFieldsWithValidationRules` us really useful as you can check a object which is already prefiled if it's valid and if not show errors.
232+
233+
The function `controllerValidByRules` will check if a validation controller is valid.
234+
235+
## Route generator service
236+
If you have router tree like this
237+
```
238+
root
239+
/ \
240+
left right
241+
```
242+
You can't navigate from `left` to `right` with `this.router.navigateToRoute(...)` as `right` is in a branch which `left` is unaware of. This is due to the injection of the router service.
243+
244+
One solution is to use `this.router.navigate(...)` but this is unsave as if the route configuration is changed the navigation is broken as it's hardcoded.
245+
246+
The `route-generator.service.ts` will provide a type safe solution for save navigation.
247+
248+
Check the following files to get an idea how to use it:
249+
- `route-generator.service.ts`
250+
- `app.vm.ts` and `app.routes.ts`
251+
- `child-router.vm.ts` and `child-router.routes.ts`
252+
253+
As an example you could navigate like this from `left` to `right`
254+
```
255+
this.routeGeneratorService.navigateByRouteNames(
256+
{ routeName: 'root' },
257+
{ routeName: 'right' }
258+
);
259+
```
260+
261+
You can also pass route parameters like this but remember that query parameter have to attached to the last element
262+
```
263+
this.routeGeneratorService.navigateByRouteNames(
264+
{ routeName: 'root', params: { id: '1' }},
265+
{ routeName: 'right' }
266+
);
267+
```

0 commit comments

Comments
 (0)