javascript - angular binding string into separate lines into html -
i have angular controller text file such in jsn
topics: 'ab, bc, cd'
is being read td field .
however, long string, trying cut string , print each word own separate line. tried creating function cut string , replace "," carriage return, still prints single line. tried inserting \n or
directly within string not work either.
<td style=" background-color: green">{{data.topics}}</td>
the data work data cannot post gist of idea. cell
'ab' 'bc' 'cd'
as opposed entire string on 1 single line of cell in table.
as long topic property, why not do.
class somecomponent implements oninit{ topics: array<string>; constructor(service: myservice) {} ngoninit() { //not sure how getting data this.service.getdata().subscribe(data => { this.topics = data.topics.split(','); }); } }
topics should array. can ng-repeat.
<td style="background-color: green" *ngfor="topic of topics">{{topic}}</td>
Comments
Post a Comment