Skip to content

Commit

Permalink
add nested outlet property documentation (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
swh-tropic committed Jun 24, 2023
1 parent b73bef7 commit 7974f63
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/reference/outlets.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ For each outlet defined in the `static outlets` array, Stimulus adds five proper
| Singular | `[name]OutletElement` | `Element` | Returns the Controller `Element` of the first `[name]` outlet or throws an exception if none is present
| Plural | `[name]OutletElements` | `Array<Element>` | Returns the Controller `Element`'s of all `[name]` outlets

**Note:** For nested Stimulus controller properties, make sure to omit namespace delimiters in order to correctly access the referenced outlet:

```js
// chat_controller.js

export default class extends Controller {
static outlets = [ "admin--user-status" ]

selectAll(event) {
// returns undefined
this.admin__UserStatusOutlets

// returns controller reference
this.adminUserStatusOutlets
}
}
```

## Accessing Controllers and Elements

Since you get back a `Controller` instance from the `[name]Outlet` and `[name]Outlets` properties you are also able to access the Values, Classes, Targets and all of the other properties and functions that controller instance defines:
Expand Down

0 comments on commit 7974f63

Please sign in to comment.