adminHuan
adminHuan

Reputation: 7

Display one field in JSON as multi line with Angular

I have a textarea component in Angular and i want to display its value (a JSON string) through [{ngModel}]. The result is image below current image

What i want is the field "Message" display as below This image i've edited by MS Paint

Can anyone help me? Thank a lot.

The actual result is fist image. What i want is the second image.

Upvotes: -1

Views: 35

Answers (1)

Eliseo
Eliseo

Reputation: 58009

In a text area the character \n makes a new line.

It's looks like really the property of your object are a "literal" "\n". I imagine you have,e.g. (see the double slash)

{"Message":"ID 1000\\nBKS29...."}

And you need

{"Message":"ID 1000\nBKS29...."}

You can use replace

data={Message:data.Message.replace("\\n",\"n")}

Upvotes: 0

Related Questions