Issue
I'm working on an application where I'm providing a list of issues in the data.message on a bad request.
The issue that I'm running into is I would like to add a line break after each error to make it look better. I tried to do a string replace and that didn't work. I also tried to add a "
" to each message. Unfortunately, that didn't work and it just outputed the break tags.
Does anyone have any suggestions?
This is how I'm outputting the message:
{{::serviceError.data.message}}
I've tried to add break tags and /n to the message to get it to work.
Solution
Try this!
Put this in your directive:
$scope.$watch("serviceError.data.message",
function () {
if ($scope.serviceError != null) {
var errorstring;
$scope.serviceError.data.message.split('.');
var formatedlist = "";
for (var i = 0; i < errorstring.length; i++) {
formatedlist += errorstring[i] + ".</br>";
}
$scope.errorList = formatedlist;
}
});
Put this in your html:
<div ng-bind-html="errorList"></div>
Answered By - Brett Davis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.