@angular/material/core#MatOption TypeScript Examples

The following examples show how to use @angular/material/core#MatOption. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: queryable-input.component.ts    From Smersh with MIT License 6 votes vote down vote up
fetch(params: Record<string, string> = {}): void {
    this.service
      ?.getData({ ...this.filters, ...params })
      .then(({ data }: { data: AbstractModelApplication[] }) => {
        this.records = data.map((item) => ({
          label: item[this.source] ?? item.id,
          value: item['@id'],
        }));

        if (Array.isArray(this.item)) {
          this.selectedRecords = this.item.map(
            (item) =>
              ({
                label: item.label ?? item[this.source] ?? item.id,
                value: item.value ?? item['@id'],
              } as unknown)
          ) as MatOption[];
        } else {
          this.retrieveInformations(data).then((item) => {
            if (item) {
              this.queryableInputControl.setValue({
                label: item[this.source] ?? item.id,
                value: item['@id'],
              });
            }
          });
        }
      });
  }
Example #2
Source File: select.component.ts    From open-source with MIT License 6 votes vote down vote up
completeParams(params: Partial<DynMatSelectParams>): DynMatSelectParams {
    function compareWith(o1: any, o2: any): boolean {
      return o1 == o2;
    }

    function sortComparator(a: MatOption, b: MatOption): number {
      return a.value.localeCompare(b.value);
    }

    return {
      ...params,
      placeholder: params.placeholder || '',
      multiple: Boolean(params.multiple),
      options: params.options || [],
      compareWith: params.compareWith || compareWith,
      sortComparator: params.sortComparator || sortComparator,
      panelClass: params.panelClass || '',
    };
  }
Example #3
Source File: queryable-input.component.ts    From Smersh with MIT License 5 votes vote down vote up
remove({ value }: MatOption): void {
    this.selectedRecords = this.selectedRecords.filter(
      (item) => item.value !== value
    );
    this.updateValue.emit({ [this.name]: this.selectedRecords });
  }
Example #4
Source File: queryable-input.component.ts    From Smersh with MIT License 5 votes vote down vote up
public record: MatOption = null;
Example #5
Source File: queryable-input.component.ts    From Smersh with MIT License 5 votes vote down vote up
public selectedRecords: MatOption[] = [];
Example #6
Source File: classification.component.ts    From HeartBeat with MIT License 5 votes vote down vote up
@ViewChild('allSelected') private allSelected: MatOption;
Example #7
Source File: crews.component.ts    From HeartBeat with MIT License 5 votes vote down vote up
@ViewChild('allSelected') private allSelected: MatOption;