Using HTML in ion-radio label


#1

I’ve come across the need to use a small amount of HTML in the label for a set of radio buttons. I’m rendering the radios using ion-radio, such as:

<ion-radio ng-repeat="answer in poll.answers" ng-model="response.answer" ng-value="answer">{{ answer.answer }}</ion-radio>

This of course escapes HTML in {{ answer.answer }}, which is an issue for me. I need to send it through a custom filter and display it as HTML. Typically, you’d approach it like:

<ion-radio ng-repeat="answer in poll.answers" ng-model="response.answer" ng-value="answer" ng-bind-html="answer.answer | myCustomFilter"></ion-radio>

However, that takes it a bit too literally and will only render that text, and not all the label and input markup necessary for the ion-radio element.

Is there any way to render un-escaped HTML in my label without just implementing this functionality and markup manually?


#2

Here’s an example of using ng-bind-html


#3

Ahh, well now don’t I feel silly that I didn’t think of just doing that. Perfect, thank you!


#4

No worries, :smile: Happy to be able to help