Skip to content

Commit cab7772

Browse files
licrtfpessoa
authored andcommitted
add Angular4 usage
1 parent 5b8ef31 commit cab7772

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,55 @@ It will now be available as a global variable named `Diff2Html`.
7474
let diff2html = require("diff2html").Diff2Html
7575
```
7676

77+
### Angular
78+
79+
* Typescript
80+
81+
```typescript
82+
// import diff2html
83+
import {Diff2Html} from 'diff2html'
84+
import {Component, OnInit} from '@angular/core';
85+
86+
87+
export class AppDiffComponent implements OnInit {
88+
outputHtml: string;
89+
constructor() {
90+
this.init();
91+
}
92+
93+
ngOnInit() {
94+
}
95+
96+
init() {
97+
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";
98+
let outputHtml = Diff2Html.getPrettyHtml(strInput, {inputFormat: 'diff', showFiles: true, matching: 'lines'});
99+
this.outputHtml = outputHtml;
100+
}
101+
}
102+
```
103+
104+
* HTML
105+
106+
```html
107+
<!DOCTYPE html>
108+
<html>
109+
<head>
110+
<title>diff2html</title>
111+
</head>
112+
<body>
113+
<div [innerHtml]="outputHtml"></div>
114+
</body>
115+
</html>
116+
```
117+
118+
* `.angular-cli.json` - Add styles
119+
120+
```json
121+
"styles": [
122+
"diff2html.min.css"
123+
]
124+
```
125+
77126
## API
78127

79128
> Intermediate Json From Git Word Diff Output

0 commit comments

Comments
 (0)