Angular 使mat选项和mat选择具有不同的UI

Angular 使mat选项和mat选择具有不同的UI,angular,angular-material,Angular,Angular Material,我有一个下拉列表,其中有电话号码的国家代码。当前,我希望所选项目仅具有标志图像或代码。下拉列表中有图像、国家代码和国家名称 国家代码 {{code.country}}({{code.calling_code}}) 尝试添加: 您的代码如下所示: <mat-form-field appearance="outline" fullWidth> <mat-label>Country Code</mat-label> <mat-select #m

我有一个下拉列表,其中有电话号码的国家代码。当前,我希望所选项目仅具有标志图像或代码。下拉列表中有图像、国家代码和国家名称


国家代码
{{code.country}}({{code.calling_code}})
尝试添加


您的代码如下所示:

<mat-form-field appearance="outline" fullWidth>
  <mat-label>Country Code</mat-label>
  <mat-select #matSelect [(value)]="selectedCode" [formControlName]="helperService.appConstants.countryCode" (selectionChange)="changeSelection(selectedCode)" required>
    <!-- Add mat-select-trigger here start -->
    <mat-select-trigger>
       <img with="10px" height="10px" src="{{code.flag}}">
    </mat-select-trigger>
     <!-- Add mat-select-trigger here end -->
    <mat-option *ngFor="let code of countryCode" [value]="code.calling_code" (keypress)="numberOnly($event)&&phoneNumberValid(registerObj.userForm)">
      <img with="10px" height="10px" src="{{code.flag}}"> {{ code.country }} ({{code.calling_code}})
    </mat-option>
  </mat-select>
</mat-form-field>

国家代码
{{code.country}}({{code.calling_code}})
恭喜你提出了一个结构良好的问题

<mat-form-field appearance="outline" fullWidth>
  <mat-label>Country Code</mat-label>
  <mat-select #matSelect [(value)]="selectedCode" [formControlName]="helperService.appConstants.countryCode" (selectionChange)="changeSelection(selectedCode)" required>
    <!-- Add mat-select-trigger here start -->
    <mat-select-trigger>
       <img with="10px" height="10px" src="{{code.flag}}">
    </mat-select-trigger>
     <!-- Add mat-select-trigger here end -->
    <mat-option *ngFor="let code of countryCode" [value]="code.calling_code" (keypress)="numberOnly($event)&&phoneNumberValid(registerObj.userForm)">
      <img with="10px" height="10px" src="{{code.flag}}"> {{ code.country }} ({{code.calling_code}})
    </mat-option>
  </mat-select>
</mat-form-field>