为什么这个 Angular 变量没有绑定?
Why isn't this Angular variable binding?
知道我做错了什么 revisedprice 的值没有显示在跨度中吗?
HTML:
<div ng-app="app" ng-controller="ctrl">
<strong><span ng-bind-html="revisedprice"></span></strong>
</div>
Angular:
var app = angular.module('app',[]);
app.controller('ctrl', function($scope, $sce) {
$scope.revisedprice = "<strike></strike>";
)};
好像你没有添加 ng-sanitize js 和依赖项。
var app = angular.module('app',['ngSanitize']);
这里是 Fiddle
如果你使用 $sce
你的控制器应该是这样的,
app.controller('ctrl', function($scope, $sce) {
$scope.revisedprice = $sce.trustAsHtml("<strike></strike>"); // add trustAsHtml()
});
这是演示 Fiddle
知道我做错了什么 revisedprice 的值没有显示在跨度中吗?
HTML:
<div ng-app="app" ng-controller="ctrl">
<strong><span ng-bind-html="revisedprice"></span></strong>
</div>
Angular:
var app = angular.module('app',[]);
app.controller('ctrl', function($scope, $sce) {
$scope.revisedprice = "<strike></strike>";
)};
好像你没有添加 ng-sanitize js 和依赖项。
var app = angular.module('app',['ngSanitize']);
这里是 Fiddle
如果你使用 $sce
你的控制器应该是这样的,
app.controller('ctrl', function($scope, $sce) {
$scope.revisedprice = $sce.trustAsHtml("<strike></strike>"); // add trustAsHtml()
});
这是演示 Fiddle