Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khashayar/ng-trim-value-accessor
Angular's (missing) trim accessor to automatically trim values of input fields
https://github.com/khashayar/ng-trim-value-accessor
angular trim
Last synced: 2 days ago
JSON representation
Angular's (missing) trim accessor to automatically trim values of input fields
- Host: GitHub
- URL: https://github.com/khashayar/ng-trim-value-accessor
- Owner: khashayar
- License: mit
- Created: 2017-02-07T12:34:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T00:09:27.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T11:49:10.470Z (about 1 month ago)
- Topics: angular, trim
- Language: TypeScript
- Size: 789 KB
- Stars: 53
- Watchers: 5
- Forks: 19
- Open Issues: 20
-
Metadata Files:
- Readme: README.MD
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# TrimValueAccessor for Angular
Angular's missing trim input functionality (equivalent of AngularJS `ng-trim`)
**Caveats:**
* It's a drop-in solution, meaning it applies to all input fields as soon as this module is used.
* It does not work with inputs that are already using another value accessor, since Angular only allows one value accessor per form control. This means it cannot be used with Angular Material inputs (the `matInput` directive uses a value accessor).## Installation
To install this library, run:
```bash
$ npm install ng-trim-value-accessor --save
```## Usage
In your Angular `AppModule`:
```typescript
import { NgModule } from '@angular/core';
import { TrimValueAccessorModule } from 'ng-trim-value-accessor';@NgModule({
imports: [
TrimValueAccessorModule
]
})
export class AppModule { }
```## Opt-out
By default, it ignores all `readonly` and `input[type="password]` fields. For example the following field remains untouched:
```html
```
However if you want to *explicitly opt-out*, give a field `ng-trim-ignore` css class:
```html
```