UNPKG

@qoollo/ngx-form-url-saver

Version:

Angular directive for syncing form's data with URL query

23 lines (22 loc) 953 B
/** * Interface for the preprocessing strategy for a single form value. * Can be used to create custom handlers for certain data types. */ export interface ValueHandlingStrategy { /** * Converts a single form value to a string that can be written to query * Override this method if you want to get a custom processing strategy, for example, for dates. * * The method also obtains information about the key name of the field in the form. * If 'united' mode is selected, the key will be undefined * @param value value of one form field */ stringify(value: unknown, key?: string): string; /** * Reads the string value of one key from a query and converts it to a value that can be written to a form. * It makes sense to override together with stringify to get custom ways to read and write certain * data types. * @param value */ parse(value: string, key?: string): unknown; }