add Angular4 usage
This commit is contained in:
parent
5b8ef31d76
commit
cab77729f6
1 changed files with 49 additions and 0 deletions
49
README.md
49
README.md
|
|
@ -74,6 +74,55 @@ It will now be available as a global variable named `Diff2Html`.
|
||||||
let diff2html = require("diff2html").Diff2Html
|
let diff2html = require("diff2html").Diff2Html
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Angular
|
||||||
|
|
||||||
|
* Typescript
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// import diff2html
|
||||||
|
import {Diff2Html} from 'diff2html'
|
||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
|
export class AppDiffComponent implements OnInit {
|
||||||
|
outputHtml: string;
|
||||||
|
constructor() {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
let strInput = "--- 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 {\n+\t\terr = errnoErr(e1)\n+\t}\n+\treturn\n+}\n+\n+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n+\n func read(fd int, p []byte) (n int, err error) {\n \tvar _p0 unsafe.Pointer\n \tif len(p) > 0 {\n";
|
||||||
|
let outputHtml = Diff2Html.getPrettyHtml(strInput, {inputFormat: 'diff', showFiles: true, matching: 'lines'});
|
||||||
|
this.outputHtml = outputHtml;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>diff2html</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div [innerHtml]="outputHtml"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
* `.angular-cli.json` - Add styles
|
||||||
|
|
||||||
|
```json
|
||||||
|
"styles": [
|
||||||
|
"diff2html.min.css"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
> Intermediate Json From Git Word Diff Output
|
> Intermediate Json From Git Word Diff Output
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue