Proposal: can-scope
for exporting scope into the surrounding context.
#1362
Labels
Milestone
can-scope
for exporting scope into the surrounding context.
#1362
Proposal
As we start using components more, we will want to add methods to our components that are meant for external use. #881 was an attempt to address this issue, but in keeping with our policy of isolating the DOM and ViewModel layers, I think it's better to expect these methods to mainly be accessed through the component viewmodels.
To facilitate this, I think following something similar to what Polymer does, by providing a simple mechanism for giving easy accessible names to child scopes. These names would be accessible directly through the component templates, and further
I propose using a
can-scope
attribute for facilitating access to child component functionality in a template, and in the component's viewModel. I further propose that non-Component
html tags that use thecan-id
attribute will automatically be treated as acan-value
, and have that value be accessible instead.Concretely,
can-scope
will export the tag's scope into a name in the surrounding template. The attribute will also automatically addcan-value
-like functionality if used on a non-component.Justification and Notes
This may require #1069 for proper operation, and will be much improved by #1360. Having #1361 would also be much more valuable here, since we would be able to just directly pass arguments to child scope methods.
Examples
The text was updated successfully, but these errors were encountered: