What I did:
I have a dropdown. I also have a textarea. I enter text in textarea and I also choose words from the dropdown and add it to the textarea. I have done this part.
Problem:
Now I wanna differentiate the words which came from the dropdown. So I wanna show those particular words alone in red color. Any word entered through dropdown or any word entered by hand which is same as any one of the dropdown value should be shown in red color. This is what I am trying to do . I have searched stackoverflow but I could find any solutions. Kindly help if you guys know
Code:
My HTML:
<textarea #text [(ngModel)]='textValue' rows="10" cols="70">
</textarea>
<div>
<mat-form-field class="input-style">
<label>Dropdown</label>
<mat-select (change)="changeValue($event)">
<mat-option *ngFor="let li of list4" [value]="li">
{{li}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
My TS:
changeValue(ev) {
this.textValue += ` ${ev.value}`;
}
I have attached my stackblitz link: https://stackblitz.com/edit/angular-mat-form-field-tfw6de?file=app%2Fform-field-prefix-suffix-example.ts