I got this error because one of the users added in his post <3
Error: [$sanitize:badparse] The sanitizer was unable to parse the foll
To preserve existing ng-bind-html
behaviour without crashing you can catch the $sanitize:badparse
exception.
The ngBindHtml
component internally uses the ngSanitize
service. Inject $sanitize
into your controller and catch it.
The advantage of this versus the $sce.trustAsHtml
methods is that $sanitize
does not introduce any potential security holes (eg. javascript injection).
Controller (inject $sanitize
):
$scope.clean = function (string) {
$scope.clean = function(string) {
try {
return $sanitize(string);
} catch(e) {
return;
}
};
};
This method could be improved with a cache of the last known good value.
View: