3.0.0 • Published 5 months ago

ngx-mat-autocomplete-control v3.0.0

Weekly downloads
34
License
ISC
Repository
-
Last release
5 months ago

Install

You can install this package with npm. This package is always up-to-date with current angular version (now supports upto Angular 19) and it is based on angular material design and support to reactive forms.

npm install ngx-mat-autocomplete-control --force

USAGE

1.After installing the package, you should import the NgxMatAutocompleteControl module in the required module / (eg. app.module.ts).

import { NgxMatAutocompleteControlModule } from 'ngx-mat-autocomplete-control';
@NgModule({
  declarations: [],

  imports: [
    NgxMatAutocompleteControlModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
  1. Create a new component and use the below coding

HTML Coding

 <ngx-mat-autocomplete-control
            [control]="'userId' | autocompleteControl: userForm:'':-1"
            [options]="userList"
            [required]="true"
            [value]="'userId'"
            [refId]="'userId'"
            [refName]="'userName'"  
            [label]="'Users'" 
            [appearance]="'outline" 
            [highlightColor]="red"
            (selectionChange)="captureSelectionChange($event)"
            (propValueEvent)="captureKeyup($event)" >   
  </ngx-mat-autocomplete-control>

Typescript Coding

  userList = [
    {userId: 1, userName: 'Sriram M P' },
    {userId: 2, userName: 'Balamurugan' },
    {userId: 3, userName: 'Subashini' }, 
    {userId: 4, userName:'Narmatha'}
    ];

  userForm: FormGroup; 

 constructor(private formBuilder:FormBuilder){}

 ngOnInit() { 

    this.userForm = this.formBuilder.group({
    userId: ['', Validators.required],
    });
 }
 captureKeyup(event){

    Paramater event has two properties

    1. event.propertyName
    2. event.value

 }
 captureSelectionChange(event){

    In event we get the selected value 

 }

Configuration Options

The following optional configuration items can be used.

OptionsData type (Default)Description
controlabstractControlFormControl to which value has to be binded.
optionsarray of objects []Options object to be listed
refIdnumberValue that has to be set on formControl
refNamestringSearch term. Options are filtered based on refName
labelstringA placeholder value for your mat-select
requiredboolean (false)To make your mat-field required
highlightColorstring (black)Color that highlights the search term in the list
appearancestring ('')Appearance of your mat-field. Supported options: 'legacy' / 'standard' / 'fill' / 'outline'

Output Events

  1. propValueEvent - captureKeyup (ie.happens when keyup)
  2. selectionChange - captureSelectionChange (ie. option changed)

Contribution

If you found this useful kindly donate thorugh the below UPI Id

sribala333@ybl

ENJOY CODING :sunglasses: :computer:

3.0.0

5 months ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.1.0

3 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago