ngx-mat-select-search doesn't works











up vote
0
down vote

favorite












I wanted to implement ngx-mat-select-search in a form I use, but unfortunately, it doesn't works (I can't open the dropdown - it doesn't show me any value).



My html:



<div class="form">
<mat-form-field>
<mat-select placeholder="Kunde" name="customer" #customer="ngModel" [(ngModel)]="currentCustomer"
(ngModelChange)="dofilterCustomer()">
<ngx-mat-select-search></ngx-mat-select-search>
<mat-option *ngFor="let customer of customers | async" [value]="customer">
{{customer}}
</mat-option>
</mat-select>
</mat-form-field>
</div>


My .ts file:



import { Component, Inject, OnInit, ViewChild } from "@angular/core";
import {
MAT_DIALOG_DATA,
MatDialogRef,
MatDialogModule,
MatSelect
} from "@angular/material";
import { TableService } from "../table.service";
import { FormControl, Validators } from "@angular/forms";
import { EntryDTO, Customer } from "../../models";
import { SecurityService } from "src/app/security/security.service";
import { MatAutocompleteModule } from "@angular/material/autocomplete";
import { Observable } from "rxjs";
import { map, startWith } from "rxjs/operators";

@Component({
selector: "app-add-dialog",
templateUrl: "./add-dialog.component.html",
styleUrls: ["./add-dialog.component.css"]
})
export class AddDialogComponent implements OnInit {
constructor(
public dialogRef: MatDialogRef<AddDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: EntryDTO,
public dataService: TableService
) {}

customers!: Observable<string>;
currentCustomer = "";
forwarders!: Observable<string>;
currentForwarder = "";
bins!: Observable<string>;
currentBin = "";

@ViewChild("singleSelect") singleSelect!: MatSelect;

ngOnInit() {}

dofilterCustomer() {
this.customers = this.dataService
.getAllCustomers()
.pipe(map(customers => this.filter(customers, this.currentCustomer)));
}

dofilterForwarder() {
this.forwarders = this.dataService
.getAllForwarders()
.pipe(map(forwarders => this.filter(forwarders, this.currentForwarder)));
}

dofilterBins() {
this.bins = this.dataService
.getAllBins()
.pipe(map(bins => this.filter(bins, this.currentBin)));
}

formControl = new FormControl("", [
Validators.required
// Validators.email,
]);

getErrorMessage() {
return this.formControl.hasError("required")
? "Required field"
: this.formControl.hasError("email")
? "Not a valid email"
: "";
}

submit() {
this.dataService.addEntry(this.data);
}

onNoClick(): void {
this.dialogRef.close();
}

public confirmAdd(): void {
this.dataService.addEntry(this.data);
}

filter(values: string, current: string) {
return values.filter(value => value.toLowerCase().includes(current));
}
}


Initially I had the following code in my html. Then it worked, but i had no dropdown, just an "autocomplete-list":



<div class="form">
<mat-form-field class="example-full-width accent">
<input type="text" #input placeholder="Kunde" aria-label="Number" name="customer" #customer="ngModel" matInput
[(ngModel)]="currentCustomer" (ngModelChange)="dofilterCustomer()" [matAutocomplete]="auto1" required>
<mat-error *ngIf="formControl.invalid">{{getErrorMessage()}}</mat-error>
<mat-autocomplete #auto1="matAutocomplete">
<mat-option *ngFor="let customer of customers | async" [value]="customer">
{{customer}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
</div>


Maybe anybody could see what i am doing wrong ?



Thank you in advance.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I wanted to implement ngx-mat-select-search in a form I use, but unfortunately, it doesn't works (I can't open the dropdown - it doesn't show me any value).



    My html:



    <div class="form">
    <mat-form-field>
    <mat-select placeholder="Kunde" name="customer" #customer="ngModel" [(ngModel)]="currentCustomer"
    (ngModelChange)="dofilterCustomer()">
    <ngx-mat-select-search></ngx-mat-select-search>
    <mat-option *ngFor="let customer of customers | async" [value]="customer">
    {{customer}}
    </mat-option>
    </mat-select>
    </mat-form-field>
    </div>


    My .ts file:



    import { Component, Inject, OnInit, ViewChild } from "@angular/core";
    import {
    MAT_DIALOG_DATA,
    MatDialogRef,
    MatDialogModule,
    MatSelect
    } from "@angular/material";
    import { TableService } from "../table.service";
    import { FormControl, Validators } from "@angular/forms";
    import { EntryDTO, Customer } from "../../models";
    import { SecurityService } from "src/app/security/security.service";
    import { MatAutocompleteModule } from "@angular/material/autocomplete";
    import { Observable } from "rxjs";
    import { map, startWith } from "rxjs/operators";

    @Component({
    selector: "app-add-dialog",
    templateUrl: "./add-dialog.component.html",
    styleUrls: ["./add-dialog.component.css"]
    })
    export class AddDialogComponent implements OnInit {
    constructor(
    public dialogRef: MatDialogRef<AddDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: EntryDTO,
    public dataService: TableService
    ) {}

    customers!: Observable<string>;
    currentCustomer = "";
    forwarders!: Observable<string>;
    currentForwarder = "";
    bins!: Observable<string>;
    currentBin = "";

    @ViewChild("singleSelect") singleSelect!: MatSelect;

    ngOnInit() {}

    dofilterCustomer() {
    this.customers = this.dataService
    .getAllCustomers()
    .pipe(map(customers => this.filter(customers, this.currentCustomer)));
    }

    dofilterForwarder() {
    this.forwarders = this.dataService
    .getAllForwarders()
    .pipe(map(forwarders => this.filter(forwarders, this.currentForwarder)));
    }

    dofilterBins() {
    this.bins = this.dataService
    .getAllBins()
    .pipe(map(bins => this.filter(bins, this.currentBin)));
    }

    formControl = new FormControl("", [
    Validators.required
    // Validators.email,
    ]);

    getErrorMessage() {
    return this.formControl.hasError("required")
    ? "Required field"
    : this.formControl.hasError("email")
    ? "Not a valid email"
    : "";
    }

    submit() {
    this.dataService.addEntry(this.data);
    }

    onNoClick(): void {
    this.dialogRef.close();
    }

    public confirmAdd(): void {
    this.dataService.addEntry(this.data);
    }

    filter(values: string, current: string) {
    return values.filter(value => value.toLowerCase().includes(current));
    }
    }


    Initially I had the following code in my html. Then it worked, but i had no dropdown, just an "autocomplete-list":



    <div class="form">
    <mat-form-field class="example-full-width accent">
    <input type="text" #input placeholder="Kunde" aria-label="Number" name="customer" #customer="ngModel" matInput
    [(ngModel)]="currentCustomer" (ngModelChange)="dofilterCustomer()" [matAutocomplete]="auto1" required>
    <mat-error *ngIf="formControl.invalid">{{getErrorMessage()}}</mat-error>
    <mat-autocomplete #auto1="matAutocomplete">
    <mat-option *ngFor="let customer of customers | async" [value]="customer">
    {{customer}}
    </mat-option>
    </mat-autocomplete>
    </mat-form-field>
    </div>


    Maybe anybody could see what i am doing wrong ?



    Thank you in advance.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I wanted to implement ngx-mat-select-search in a form I use, but unfortunately, it doesn't works (I can't open the dropdown - it doesn't show me any value).



      My html:



      <div class="form">
      <mat-form-field>
      <mat-select placeholder="Kunde" name="customer" #customer="ngModel" [(ngModel)]="currentCustomer"
      (ngModelChange)="dofilterCustomer()">
      <ngx-mat-select-search></ngx-mat-select-search>
      <mat-option *ngFor="let customer of customers | async" [value]="customer">
      {{customer}}
      </mat-option>
      </mat-select>
      </mat-form-field>
      </div>


      My .ts file:



      import { Component, Inject, OnInit, ViewChild } from "@angular/core";
      import {
      MAT_DIALOG_DATA,
      MatDialogRef,
      MatDialogModule,
      MatSelect
      } from "@angular/material";
      import { TableService } from "../table.service";
      import { FormControl, Validators } from "@angular/forms";
      import { EntryDTO, Customer } from "../../models";
      import { SecurityService } from "src/app/security/security.service";
      import { MatAutocompleteModule } from "@angular/material/autocomplete";
      import { Observable } from "rxjs";
      import { map, startWith } from "rxjs/operators";

      @Component({
      selector: "app-add-dialog",
      templateUrl: "./add-dialog.component.html",
      styleUrls: ["./add-dialog.component.css"]
      })
      export class AddDialogComponent implements OnInit {
      constructor(
      public dialogRef: MatDialogRef<AddDialogComponent>,
      @Inject(MAT_DIALOG_DATA) public data: EntryDTO,
      public dataService: TableService
      ) {}

      customers!: Observable<string>;
      currentCustomer = "";
      forwarders!: Observable<string>;
      currentForwarder = "";
      bins!: Observable<string>;
      currentBin = "";

      @ViewChild("singleSelect") singleSelect!: MatSelect;

      ngOnInit() {}

      dofilterCustomer() {
      this.customers = this.dataService
      .getAllCustomers()
      .pipe(map(customers => this.filter(customers, this.currentCustomer)));
      }

      dofilterForwarder() {
      this.forwarders = this.dataService
      .getAllForwarders()
      .pipe(map(forwarders => this.filter(forwarders, this.currentForwarder)));
      }

      dofilterBins() {
      this.bins = this.dataService
      .getAllBins()
      .pipe(map(bins => this.filter(bins, this.currentBin)));
      }

      formControl = new FormControl("", [
      Validators.required
      // Validators.email,
      ]);

      getErrorMessage() {
      return this.formControl.hasError("required")
      ? "Required field"
      : this.formControl.hasError("email")
      ? "Not a valid email"
      : "";
      }

      submit() {
      this.dataService.addEntry(this.data);
      }

      onNoClick(): void {
      this.dialogRef.close();
      }

      public confirmAdd(): void {
      this.dataService.addEntry(this.data);
      }

      filter(values: string, current: string) {
      return values.filter(value => value.toLowerCase().includes(current));
      }
      }


      Initially I had the following code in my html. Then it worked, but i had no dropdown, just an "autocomplete-list":



      <div class="form">
      <mat-form-field class="example-full-width accent">
      <input type="text" #input placeholder="Kunde" aria-label="Number" name="customer" #customer="ngModel" matInput
      [(ngModel)]="currentCustomer" (ngModelChange)="dofilterCustomer()" [matAutocomplete]="auto1" required>
      <mat-error *ngIf="formControl.invalid">{{getErrorMessage()}}</mat-error>
      <mat-autocomplete #auto1="matAutocomplete">
      <mat-option *ngFor="let customer of customers | async" [value]="customer">
      {{customer}}
      </mat-option>
      </mat-autocomplete>
      </mat-form-field>
      </div>


      Maybe anybody could see what i am doing wrong ?



      Thank you in advance.










      share|improve this question















      I wanted to implement ngx-mat-select-search in a form I use, but unfortunately, it doesn't works (I can't open the dropdown - it doesn't show me any value).



      My html:



      <div class="form">
      <mat-form-field>
      <mat-select placeholder="Kunde" name="customer" #customer="ngModel" [(ngModel)]="currentCustomer"
      (ngModelChange)="dofilterCustomer()">
      <ngx-mat-select-search></ngx-mat-select-search>
      <mat-option *ngFor="let customer of customers | async" [value]="customer">
      {{customer}}
      </mat-option>
      </mat-select>
      </mat-form-field>
      </div>


      My .ts file:



      import { Component, Inject, OnInit, ViewChild } from "@angular/core";
      import {
      MAT_DIALOG_DATA,
      MatDialogRef,
      MatDialogModule,
      MatSelect
      } from "@angular/material";
      import { TableService } from "../table.service";
      import { FormControl, Validators } from "@angular/forms";
      import { EntryDTO, Customer } from "../../models";
      import { SecurityService } from "src/app/security/security.service";
      import { MatAutocompleteModule } from "@angular/material/autocomplete";
      import { Observable } from "rxjs";
      import { map, startWith } from "rxjs/operators";

      @Component({
      selector: "app-add-dialog",
      templateUrl: "./add-dialog.component.html",
      styleUrls: ["./add-dialog.component.css"]
      })
      export class AddDialogComponent implements OnInit {
      constructor(
      public dialogRef: MatDialogRef<AddDialogComponent>,
      @Inject(MAT_DIALOG_DATA) public data: EntryDTO,
      public dataService: TableService
      ) {}

      customers!: Observable<string>;
      currentCustomer = "";
      forwarders!: Observable<string>;
      currentForwarder = "";
      bins!: Observable<string>;
      currentBin = "";

      @ViewChild("singleSelect") singleSelect!: MatSelect;

      ngOnInit() {}

      dofilterCustomer() {
      this.customers = this.dataService
      .getAllCustomers()
      .pipe(map(customers => this.filter(customers, this.currentCustomer)));
      }

      dofilterForwarder() {
      this.forwarders = this.dataService
      .getAllForwarders()
      .pipe(map(forwarders => this.filter(forwarders, this.currentForwarder)));
      }

      dofilterBins() {
      this.bins = this.dataService
      .getAllBins()
      .pipe(map(bins => this.filter(bins, this.currentBin)));
      }

      formControl = new FormControl("", [
      Validators.required
      // Validators.email,
      ]);

      getErrorMessage() {
      return this.formControl.hasError("required")
      ? "Required field"
      : this.formControl.hasError("email")
      ? "Not a valid email"
      : "";
      }

      submit() {
      this.dataService.addEntry(this.data);
      }

      onNoClick(): void {
      this.dialogRef.close();
      }

      public confirmAdd(): void {
      this.dataService.addEntry(this.data);
      }

      filter(values: string, current: string) {
      return values.filter(value => value.toLowerCase().includes(current));
      }
      }


      Initially I had the following code in my html. Then it worked, but i had no dropdown, just an "autocomplete-list":



      <div class="form">
      <mat-form-field class="example-full-width accent">
      <input type="text" #input placeholder="Kunde" aria-label="Number" name="customer" #customer="ngModel" matInput
      [(ngModel)]="currentCustomer" (ngModelChange)="dofilterCustomer()" [matAutocomplete]="auto1" required>
      <mat-error *ngIf="formControl.invalid">{{getErrorMessage()}}</mat-error>
      <mat-autocomplete #auto1="matAutocomplete">
      <mat-option *ngFor="let customer of customers | async" [value]="customer">
      {{customer}}
      </mat-option>
      </mat-autocomplete>
      </mat-form-field>
      </div>


      Maybe anybody could see what i am doing wrong ?



      Thank you in advance.







      angular typescript angular-material






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 13:28









      veben

      522419




      522419










      asked Nov 19 at 13:14









      Shorty

      156




      156





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375443%2fngx-mat-select-search-doesnt-works%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375443%2fngx-mat-select-search-doesnt-works%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python