Reputation: 7
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
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