因此,我正在嘗試製作一個簡單的小型pastebin,這對我來說主要是一項技術學習練習。我把一切都在前臺工作,除了highlight.js(庫任意選擇)嘗試將highlight.js集成到使用requirejs的角度應用程序
這裏是我的控制器
define([
'highlight',
'angular',
], function(hl) {
'use strict';
return [ '$scope', '$location', '$routeParams', 'pastes',
function ($scope, $location, $routeParams, pastes) {
console.log(pastes);
var digest = $routeParams.digest;
if (pastes[digest]) {
$scope.code = hl.highlightAuto(pastes[digest]).value;
console.log($scope.code);
}
$scope.view = function(view) {
$location.path(view);
}
$scope.$apply();
}];
});
和我的觀點
<pre ng-controller="Render"><code class="pre-scrollable">
{{code}}
</code></pre>
<button
type="button"
class="btn btn-primary pull-right"
ng-click="view('/')"
>New Paste</button>
要對得起這個代碼工作,問題是{{code}}
似乎是消毒正在吐出的html,所以我需要找到另一種方式來做到這一點。嘗試了其他一些圖書館的咒語,但沒有任何進展。
這裏的[我的代碼](https://bitbucket.org/xenoterracide/pastey-frontend/src/9e5ff8b761c9?at=master)的情況下,我已經離開了一個相關位 – xenoterracide