工作,我尝试使用添加类似动态HTML NG绑定,HTML,但它不是以$ scope变量工作
这里是我的角码
1)我的控制器
$scope.name = "Parshuram"
$scope.thisCanBeusedInsideNgBindHtml = $sce.trustAsHtml("<div>{{name}}</div>");
也是我的字符串是动态
"<div><table class=" + "\"table table - bordered table - responsive table - hover add - lineheight table_scroll\"" + "><thead><tr><td>Name</td><td>Age</td></tr></thead><tbody><tr ng-repeat=" + "\"tr in dyna\"" + "><td>{{tr.name}}</td><td>{{tr.age}}</td></tr></tbody></table></div>"
,所以我不能replac e为$范围
2)每个变量 - 我的HTML
<div ng-app="mymodule" ng-controller="myModuleController">
<div ng-bind-html="thisCanBeusedInsideNgBindHtml"></div>
</div>
我得到这个输出
{{name}}
我的预期输出是
Parshuram
请谁能帮助我卡住在这一点上,这$ sce不绑定范围变量? ..
如果你从服务器获取该html,并且可以让服务器返回一个恰好是你想要的html的响应,那么就使用'ng-include =“'// theserver/somepage'”'将获取html并将其包含为模板。 – Duncan
你能否详细解释一下,这是我的返回HTML字符串服务 –
$ http.get('http:// localhost:22475/api/mymodule').then(function(response){ console.log(response。数据);}); –