I have a processed backend template that returns a JSON object that contains a string that requires some dynamic data bindings, for example ...
sampleLogic = { "1": "Sample static text and some {{ dynamic_text }}." }
By default, the string is escaped, what is the best way in angular to convert dynamic_text to bind to $ scope.dynamic_text?
JS:
var sampleLogic = { "1": "Sample static text and some {{ dynamic_text }}." }; function parseMe($scope) { $scope.copy = sampleLogic['1']; $scope.dynamic_text = "dynamic text woooot"; }
HTML:
<div ng-app> <div ng-controller="parseMe"> <div ng-bind-html-unsafe="copy"></div> </div> </div>
Violin: http://jsfiddle.net/RzPM3/
Rob b source share