3

I am using the ng-select drop-down list. If I use ng-option then if it gets "&" it adds "amp;" with "&". But if I only use ng-select it works perfectly. I can not use any directives to replace value because in the background the value does not change. But at the time of showing it adds "amp;".

 <ng-select [clearable]="false" (change)="onChangeBusinessUnit()" [disabled]="model.canChangeBusinessUnit != 1"
              [(ngModel)]="model.selectBusinessUnit" name="selectBusinessUnit">
              <ng-option value="">{{ langService.langData.select }}</ng-option>
              <ng-option *ngFor="let businessUnit of model.businessUnitList" [value]="businessUnit.BU_NO">{{
                businessUnit.BU_NAME }}</ng-option>
            </ng-select>

In the drow-down show likes

See in the stackblitz: https://stackblitz.com/edit/ng-select-i19fsr?file=app/app.component.ts

Sabbir
  • 327
  • 5
  • 14

1 Answers1

0

You can try manually updating &amp ; with replace

{{ value.replace(/&amp ;/g, '&') }}

For what it's worth, HTML should automatically translate &amp; to &. It seems like you have a rogue spacebar inside of &amp ; which is preventing that from happening or create Pipe like this {{value | [pipe]}}

abney317
  • 7,760
  • 6
  • 32
  • 56
mosi98
  • 575
  • 6
  • 16
  • nice try but unfortunately does not work. I have also made a pipe. But when I send or get the value it goes absolutely fine. In the time of showing dropdown, it adds "amp;", – Sabbir Mar 05 '19 at 07:01