我有一个后端渲染模板,它返回一个 JSON 对象,其中包含一个需要一些动态数据绑定的字符串,例如......
sampleLogic = {
"1": "Sample static text and some {{ dynamic_text }}."
}
默认情况下,字符串被转义,角度转换dynamic_text以绑定到$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>
小提琴:http: //jsfiddle.net/RzPM3/