I've never seen an API do this before, but I'm working with what I've got. This is part of the response body from the API I'm dealing with
"body": {
"isRichText":true,
"messageSegments":[
{
"htmlTag":"p",
"markupType":"Paragraph",
"text":"",
"type":"MarkupBegin"
},
{
"text":"This is a ",
"type":"Text"
},
{
"htmlTag":"b",
"markupType":"Bold",
"text":"",
"type":"MarkupBegin"
},
{
"text":"post",
"type":"Text"
},
{
"htmlTag":"b"
,"markupType":"Bold",
"text":"",
"type":"MarkupEnd"
},
{
"text":" from the standard ",
"type":"Text"
},
{
"htmlTag":"i",
"markupType":"Italic",
"text":"",
"type":"MarkupBegin"
},
{
"text":"chatter",
"type":"Text"
},
{
"htmlTag":"i",
"markupType":"Italic",
"text":"",
"type":"MarkupEnd"
},
{
"text":" UI with some HTML tags",
"type":"Text"
},
{
"htmlTag":"p",
"markupType":"Paragraph",
"text":"\n",
"type":"MarkupEnd"
}
]
}
I need to combine each one of those segments in order to create what will end up being one element inside of a paragraph tag(in this case).
HTML
<div ng-repeat="bodyElement in post.body.messageSegments">
<!-- ng-if maybe? -->{{bodyElement.htmlTag}} {{bodyElement.text}}
</div>
What is the best way to complete this? Is it directly in the js files, or should I attempt in the templates?
each.messageSegment(if htmlTag then '<' + htmlTag + '>' else text)? This is my first angular app so I'm not sure what the best way to handle this would be. The $http request is in a factory