Skip to content

Commit

Permalink
Merge pull request aurelia#1319 from CollinHerber/master
Browse files Browse the repository at this point in the history
chore(docs): add registering a custom element documentation
  • Loading branch information
bigopon authored Jan 6, 2022
2 parents 71d55a8 + b531af3 commit e420ad6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@ If you want more control over your components or you are a plugin author, you mi

{% page-ref page="using-customelement-decorator.md" %}

## Register your Custom Element

To enable the custom markup to be available within your template or globally you must register your element.

{% page-ref page="consuming-a-custom-element.md" %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Consuming a Custom Element
In order to use a new component you must register your component either globally or within the component you would like to use it in.

## Globally registering an element
To register your component to be used globally within your application you will use `.register` in `main.ts`
```javascript
import Aurelia from 'aurelia';
import { MyApp } from './my-app';
import { SomeElement } from './path-to/some-element';

Aurelia
.register(SomeElement)
.app(MyApp)
.start();
```

## Importing the element within the template
Adding your element to be used within the template is as easy as adding the following line in your `.html` file.
```html
<import from="./path-to/some-element"></import>
```

0 comments on commit e420ad6

Please sign in to comment.