0
Syntax Error: Token '<' not a primary expression at column 1 of the expression [<div>I think happiness is key to everything</div>] starting at [<div>I think happiness is key to everything</div>].
html
--------------------
<p dynamic="<div>I think happiness is key to everything</div>"></p>
directive
---------------------
app.directive('dynamic', function($compile){
return function(scope, element, attrs) {
scope.$watch(
function(scope) {
return scope.$eval(attrs.dynamic);
},
function(value) {
element.html(value);
$compile(element.contents())(scope);
}
);
};
});
不知道爲什麼會產生錯誤。我嘗試了角度錯誤頁面,但找不到合適的答案。我用這個angular ng-bind-html and directive within it來解決我的問題,但它會引發錯誤。任何幫助是極大的讚賞。謝謝