angular2 template - Displaying special symbols in Angular 4 -


i getting value using ngmodel back-end in text box. linked searchable drop-down (which populate using <p> tags , using innerhtml).

if should display registered trademark symbols in text box, how do it? ideas? or angular directives?

the values getting saved in db html byte characters service sync (for eg., registered trademark &#174;)

<div class="top-selection">                     <input type="text" class="" placeholder="type here select brand" (blur)="checkproperdata()"                            id="brand-id" #brand_id="ngmodel" [(ngmodel)]="cmpgnctgry['brand_id']"                            name="brand_id" (click)="showbrands(row_no)" (keyup)=filter(row_no)/>                      <div class="filterbox width300px" *ngif="disableshow[row_no]">                         <div *ngfor="let brand of brandlist">                             <p [innerhtml]="brand.brandname" (click)="selectcatalogid(brand.brandname, brand.branduniqueid, brand.brandid, row_no)">                                 {{brand.brandname}}</p>                         </div>                     </div>                 </div> 

i talking box reads brand_id here

i tried doing following,

var p = document.createelement('div');                         p.textcontent = this.campaign['cmpgn_dtl_tx'].cmpgn_ctgry[i].brand_id;                         this.campaign['cmpgn_dtl_tx'].cmpgn_ctgry[i].brand_id = p.innerhtml;                         console.log(p.innerhtml); 

i didn't understand why wasn't working. have implemented in .ts component file. logging won't help? (it not getting updated in html either).

also, i'm surprised there no standard way of converting registered trademark - have use regular expressions , replace < or & symbols.

a normal [(ngmodel)] should bind unicode symbol correctly

template

<div>     <input [(ngmodel)]="brand" /> </div> 

component

brand = "google™©®" 

screenshot

enter image description here

for information on how encode , decode html entities when saving to/reading database see these questions:

  1. encoding
  2. decoding

plunker example


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -