CustomElement API
CustomElement.for
Usage Examples
Retrieving a Controller for the Current Node
import { CustomElement } from 'aurelia';
const myElement = document.querySelector('.my-custom-element');
try {
const controller = CustomElement.for(myElement);
// You can now interact with the custom element's controller
} catch (error) {
console.error('The provided node does not host a custom element.', error);
}Searching Parent Nodes for a Controller
const someInnerElement = document.querySelector('.some-inner-element');
const parentController = CustomElement.for(someInnerElement, { searchParents: true });
// parentController is the closest controller up the DOM tree from someInnerElementGetting a Controller for a Named Custom Element
Retrieving a Controller Without Throwing an Error
Parameters
Return Value
CustomElement.define
Usage Examples
Defining a Custom Element with a Name
Defining a Custom Element with a Definition Object
Parameters
Return Value
CustomElement.getDefinition
Usage Example
Parameters
Return Value
CustomElement.annotate and CustomElement.getAnnotation
Usage Examples
Annotating a Custom Element Class
Retrieving an Annotation from a Custom Element Class
Parameters
Return Value
CustomElement.generateName
Usage Example
Return Value
CustomElement.createInjectable
Usage Example
Return Value
CustomElement.generateType
Usage Example
Parameters
Return Value
Last updated
Was this helpful?