Guest User

Untitled

a guest
Jan 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <mat-form-field>
  2. <input matInput #nation placeholder="{{'customer.detail.labels.country'
  3. | translate }}" required [matAutocomplete]="tdAuto" name="country"
  4. #count="ngModel" [(ngModel)]="selected.country"
  5. (ngModelChange)="searchCountry($event)">
  6. <mat-autocomplete #tdAuto="matAutocomplete" [displayWith]="displayFn">
  7. <mat-option (onSelectionChange)="setCountry(country)" *ngFor="let country of countries" [value]="country">
  8. <div class="row">
  9. <img src="assets/img/flags24/{{country.alpha2Code | lowercase}}.png" />
  10. <span>{{country.name}} ({{country.alpha2Code}})</span>
  11. </div>
  12. </mat-option>
  13. </mat-autocomplete>
  14. </mat-form-field>
  15.  
  16. @ViewChild('nation', { read: MatAutocompleteTrigger }) trigger: MatAutocompleteTrigger;
  17. subscription: Subscription;
  18.  
  19.  
  20. ngAfterViewInit() {
  21. this.countryClosingActions();
  22. }
  23.  
  24. private countryClosingActions(): void {
  25. if (this.subscription && !this.subscription.closed) {
  26. this.subscription.unsubscribe();
  27. }
  28.  
  29. this.subscription = this.trigger.panelClosingActions
  30. .subscribe(e => {
  31. console.log('closing')
  32. if (!e || !e.source) {
  33. this.selected.country = null;
  34. this.selfCountry = null;
  35. }
  36. },
  37. err => this.countryClosingActions(),
  38. () => this.countryClosingActions());
  39. }
Add Comment
Please, Sign In to add comment