I have created a factory to retrieve json data from my backend. Parts of the json data is heavily text-based and needs to convert line breaks into coupled <p></p> tags.
I tried to use this function to process the text in my view file.
function TextProcess(text) {
var p_text = text.replace("/[\r\n]+/", "</p><p>")+"</p>";
var finish_text = p_text.replace("/(?<=\s)\x20|\x20(?=\s)/", " ");
return(finish_text);
}
It is possible that this function has its own problem...(I'm very new to javascript)
Then in view, I tried:
<p>{{TextProcess(article.body)}}</p>
This line gets me nowhere.
Is what I am doing the right way to process text in AngularJS? I have no idea how to process Json data using AngularJS without the help of ng-repeat.
Please tell me what to do.