Skip to content

Instantly share code, notes, and snippets.

@praveenpuglia
Created March 23, 2018 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save praveenpuglia/ea4e7bd50c5c9d440faec20f55cd889b to your computer and use it in GitHub Desktop.
Save praveenpuglia/ea4e7bd50c5c9d440faec20f55cd889b to your computer and use it in GitHub Desktop.
Simple Component that dumps prettified data in any template.
import { Component, Input } from '@angular/core';
@Component({
selector: 'dump',
template: `
<pre><code>{{data | json}}</code></pre>
`,
styles: [
`
:host {
display: block;
}
pre {
background: #f3f3f3;
border: 2px dashed;
font-size: 0.75rem;
padding: 1rem;
position: relative;
}
code {
overflow: auto;
max-height: 300px;
display: block;
text-shadow: 0 -1px white;
}
pre::before {
position: absolute;
left: 0;
top: 0;
content: 'Data Debug 🐛';
transform: translate3d(50%, -50%, 0);
padding: 0.25rem;
color: tomato;
border: 2px solid black;
background: white;
}
`
]
})
export class DataDumpComponent {
@Input() data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment