Created
October 14, 2019 16:27
-
-
Save angelo510/b39570b5dcc0c7dc90a42b894b48f1f7 to your computer and use it in GitHub Desktop.
Dropdown Component Angular Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <mr-field-container | |
| #container | |
| [fieldId]="fieldId" | |
| [label]="label" | |
| [description]="description" | |
| > | |
| <ng-select | |
| *ngIf="hasItems; else staticOptions" | |
| [labelForId]="container.fieldId" | |
| [attr.aria-describedby]="container.descriptionId" | |
| [disabled]="isDisabled" | |
| [multiple]="isMultiple" | |
| [maxSelectedItems]="maxSelectedItems" | |
| [clearable]="!disableClearing" | |
| [closeOnSelect]="!isMultiple" | |
| [searchable]="searchable" | |
| [placeholder]="placeholder" | |
| [bindValue]="valueProperty" | |
| [bindLabel]="displayProperty || valueProperty" | |
| [compareWith]="compareWith" | |
| [items]="items" | |
| [loading]="!items" | |
| [typeahead]="searchTermChanges" | |
| [(ngModel)]="value" | |
| (ngModelChange)="onChange($event)" | |
| (blur)="onBlur()" | |
| ></ng-select> | |
| <!-- | |
| TODO: Figure out how to exclude or programmatically set ng-select's item | |
| property so we don't have to duplicate this for the static, ng-option case. | |
| --> | |
| <ng-template #staticOptions> | |
| <ng-select | |
| [labelForId]="container.fieldId" | |
| [attr.aria-describedby]="container.descriptionId" | |
| [disabled]="isDisabled" | |
| [multiple]="isMultiple" | |
| [maxSelectedItems]="maxSelectedItems" | |
| [clearable]="!disableClearing" | |
| [closeOnSelect]="!isMultiple" | |
| [searchable]="searchable" | |
| [placeholder]="placeholder" | |
| [compareWith]="compareWith" | |
| [(ngModel)]="value" | |
| (ngModelChange)="onChange($event)" | |
| (blur)="onBlur()" | |
| > | |
| <ng-option *ngFor="let option of options" [value]="option.value">{{ | |
| option.content | |
| }}</ng-option> | |
| </ng-select> | |
| </ng-template> | |
| </mr-field-container> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment