我正在尝试美化一些动态生成的文本。
<div ng-app="Knob" ng-controller="myCtrl">
<pre class="prettyprint">{{text}}</pre>
</div>
var App = angular.module('Knob', []);
App.controller('myCtrl', function($scope) {
$scope.text = "hello world";
})
App.directive('prettyprint', function() {
return {
restrict: 'C',
link: function postLink(scope, element, attrs) {
prettyPrint();
}
};
});
输出:
hello worldtext}}
任何想法为什么?