Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <mat-form-field>
- <input matInput #nation placeholder="{{'customer.detail.labels.country'
- | translate }}" required [matAutocomplete]="tdAuto" name="country"
- #count="ngModel" [(ngModel)]="selected.country"
- (ngModelChange)="searchCountry($event)">
- <mat-autocomplete #tdAuto="matAutocomplete" [displayWith]="displayFn">
- <mat-option (onSelectionChange)="setCountry(country)" *ngFor="let country of countries" [value]="country">
- <div class="row">
- <img src="assets/img/flags24/{{country.alpha2Code | lowercase}}.png" />
- <span>{{country.name}} ({{country.alpha2Code}})</span>
- </div>
- </mat-option>
- </mat-autocomplete>
- </mat-form-field>
- @ViewChild('nation', { read: MatAutocompleteTrigger }) trigger: MatAutocompleteTrigger;
- subscription: Subscription;
- ngAfterViewInit() {
- this.countryClosingActions();
- }
- private countryClosingActions(): void {
- if (this.subscription && !this.subscription.closed) {
- this.subscription.unsubscribe();
- }
- this.subscription = this.trigger.panelClosingActions
- .subscribe(e => {
- console.log('closing')
- if (!e || !e.source) {
- this.selected.country = null;
- this.selfCountry = null;
- }
- },
- err => this.countryClosingActions(),
- () => this.countryClosingActions());
- }
Add Comment
Please, Sign In to add comment