たとえば、いくつかの動的データ バインディングを必要とする文字列を含む JSON オブジェクトを返すバックエンド レンダリング テンプレートがあります。
sampleLogic = {
"1": "Sample static text and some {{ dynamic_text }}."
}
デフォルトでは、文字列はエスケープされます.angularで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>