$sce.trustAsHtml rejects numeric values
When the data have int values to be printed into choices span, it gets error:
Error: [$sce:itype] Attempted to trust a non-string value in a content requiring a string: Context: html
// ERROR on value = 1;
// OK on value = "1"
scope.trustAsHtml = function(value) {
return $sce.trustAsHtml(value);
};
I've used string conversion to overcome:
return $sce.trustAsHtml("" + value);
Btw, in the test I have 3 select fields with 1 element in each.
I'm using only one trustAsHtml() (just span, without small)
I get 21 errors on page load. Why it is so much?
Another error, because number is not a string, and does not have replace method.
TypeError: Object 92 has no method 'replace'
Edit: obsolete message according to ui-select v0.1.0
Obviously it only works with strings, so you will have to use toString():
<choices data="people | filter: $select.search">
<div ng-bind-html="trustAsHtml((item.name | highlight: $select.search))"></div>
<small ng-bind-html="trustAsHtml((item.age.toString() | highlight: $select.search))"></small>
</choices>
I have pushed a new release and ui-select does not provide function trustAsHtml() anymore, you should use ngSanitize instead (or create your own trustAsHtml() function using $sce)
More explanations inside the FAQ