@gudhub/gh-html-element
v1.4.5
Published
This is web component which use to create elements
Downloads
25
Readme
GH HTML ELEMENT
Attributes
app-id
- application id of elementitem-id
- item id of elementfield-id
- field id of elementvalue
- value of elementgh-model
- path to object where save or get value from element
Available methods
render
- It's used for render html in component. You need pass html to this method.observe
- Method for binding data in component. This method expect for variable name and callback. Here is example:
class Simple extends GhHtmlElement {
constructor() {
super();
this.text = 'Text';
}
connectedCallback() {
this.render()
this.observe('text', () => {
this.render();
});
}
render () {
this.innerHTML = `<p>${this.text}</p>`;
}
}
window.customElements.define('simple-element', Simple);
const simple = document.createElement('simple-element');
setTimeout(() => {
simple.data.text = 'Hello World!';
}, 1000)
document.body.append(simple);