angular-formatter-parser

  • When you custom a custom validator you implement the on your custom validation function.
  • Then you implement and use the token to hook into the validation section and provide your custom function as a validator.
  • , the array of transform functions that are called when the model changes and updates the value.
  • To register our transform functions we use the token to provide our functions

    To apply validators to a you setup an array of validator functions, default or custom and provide it under the validators key in the constructor parmas.

  • But instead of providing an array of validator functions use just provide an array of strings that are the name of the transform functions.

Angular Formatter Parser – The AngularJS Port

@nodenpm: angular-formatter-parser (0.1.0): Angular Formatter Parser – The AngularJS Port

The angular FormatterParser library in a port of the Angular1

ngModel.$formatter

and

ngModel.§parser

Like the

Validators

service provides a set default validation functions there is a

When you custom a custom validator you implement the

on your custom validation function. Then you implement

and use the

NG_VALIDATORS

Same with transform functions with a little more options. As you know in angular1 we have

$parser

and

$formatter

$parser

, the array of transform functions that are called when the model changes and updates the

value. And

$formatter

, the array of transform functions that are called when the

fires it’s input event with changes and updates the model.

We hook into the two directions by using the

for the

$formatter

direction, and the

@HostListener(‘input’)

to hook into the

$parser

To register our transform functions we use the

FORMATTER_PARSER

To apply validators to a

you setup an array of validator functions, default or custom and provide it under the validators key in the

To apply transform functions to a

use use the

formatterParser

directive which also binds a config array. But instead of providing an array of validator functions use just provide an array of strings that are the name of the transform functions. the directive automatically recogizes the strings and finds the related transform function. Your custom transform functions can be registered under

FORMATTER_PARSER

, similar as you would with

NG_VALIDATORS

angular-formatter-parser

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.