2014-11-04 37 views
1

我是Angular.js的新手,所以我知道這是太基本的問題,但在這裏看起來只有找到angular.js問題答案的地方。ngBindHtml不支持ngSanitize

<!doctype html> 
<html ng-app="example"> 
<head> 
<script src="angular.min.js"></script> 
<script src="angular.sanitize.min.js"></script> 
<script> 
var example = angular.module("example", ['ngSanitize']); 
example.controller("exampleCtrl", function($scope){ 
    $scope.appTitle = "<b>Example Angular App</b>"; 
}); 
</script> 
</head> 
<body ng-controller="exampleCtrl"> 
    <h1 ng-bind-html="appTitle"></h1> 
</body> 
</html> 

我遵循Rodrigo Branas(Angular.js Essentials)的書。他只是使用「停車」這個詞作爲變量的名字而不是「例子」。

我不知道是否有更新angular.js等?

+0

'angular.min.js'應該頂部所有角模塊。 – 2014-11-04 10:56:34

+0

@RahilWazir我剛剛更新。 – 2014-11-04 10:58:15

+0

'ng-bind-html'現在應該可以工作 – 2014-11-04 10:58:46

回答

0

顯示在$範圍使用的物品:

<h1>{{ appTitle }}</h1> 

結帳此小提琴:http://jsfiddle.net/zn7osxt6/

+0

它應該工作在OP當前有 – 2014-11-04 11:07:20

+0

那個小提琴沒有顯示ng-bind-html指令的用法。 – 2014-11-04 11:10:29

+0

如果它是關於顯示文本爲什麼使用怪異的過時指令時,你可以用簡單的語法來綁定所有的東西? – Charlie 2014-11-04 11:12:35