fromAttribute
Create a property and attribute binding on a StacheElement
.
fromAttribute
Using fromAttribute
will set up attribute and property bindings for a StacheElement
:
<my-el name="Matt"></my-el>
<script type="module">
import { fromAttribute, StacheElement } from "can";
class MyElement extends StacheElement {
static view = `
<p>{{this.name}}</p>
`;
static props = {
name: { type: String, bind: fromAttribute }
};
}
customElements.define("my-el", MyElement);
</script>
Purpose
For creating bindings on a StacheElement
for attributes and properties. If you set an attribute that will be reflected within the StacheElement
properties.