我试图使用格式化的角度指令内部的差异diff2html和var jq = $.noConflict();
我创建了一个Angular常量来保存jQuery并将其传递给指令,如下所示:
app.js
(function () { //IIFE to enable strict mode
'use strict';
angular.module('dashboard', ['ui.router', 'ngSanitize'])
.config(['$interpolateProvider', function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[[').endSymbol(']]]');
}])
.constant('jQuery', window.jQuery);
})();
Run Code Online (Sandbox Code Playgroud)
directive.js
(function () { //IIFE to enable strict mode
'use strict';
angular.module('dashboard')
.directive("loadDiff", ['$http', 'jQuery', function($http, $) {
return {
restrict: "A",
link: function(scope, elem, attrs) {
$http.get("diff url here").success(function (data) {
var diff2htmlUi = new Diff2HtmlUI({diff: data});
diff2htmlUi.draw('#line-by-line');
});
}
}
}]);
})();
Run Code Online (Sandbox Code Playgroud)
问题
运行时,我收到以下错误:
TypeError: $ is …
diff_match_patch 可以用来创建可以在 diff2html 中使用的统一 diff 字符串吗?
是否有一个库可以从diff2html可以使用的两个字符串中生成统一的差异?我试过difflib但输出似乎不符合 diff2html 需要的要求。我需要一个 .js 库,我可以在网页中导入以生成 JSON 之间的差异。
尝试使用该lineterm参数,但无法使该工具正常工作。如果我使用文档中的字符串作为示例,那么它可以工作:
--- a/server/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go\n+++ b/server/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go\n@@ -1035,6 +1035,17 @@ func Prctl(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (\n \n // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n \n+func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {\n+\tr0, _, e1 := Syscall6(SYS_PSELECT6, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)))\n+\tn = int(r0)\n+\tif e1 != 0 …Run Code Online (Sandbox Code Playgroud)