Closed yelvert closed 9 years ago
I feel like I'm not quite understanding the request. Begging your patience....would you mind trying to explain it a little more for me please?
After rereading it, I can understand the confusion. I'll try to put a "how I would expect it to work" together tomorrow, if I get a chance.
Something like this. https://gist.github.com/yelvert/1c2eb29b1cde45364fff Basically the equivalent of the &attr scope binding from angular.
@EisenbergEffect do we need the equivalent of knockout's $data
added to the scope in the same fashion as $event
? Might be better to handle this as a special case in AccessScope
and return scope
when scope
does not have a pre-existing $data
property.
Similarly, we could also take care of https://github.com/aurelia/binding/issues/11 by making AccessScope
handle a special $global
token. This way accessing the global scope is explicit, but not difficult.
Thoughts?
Also wondering what we should name this? $scope
? $data
?
A duplicate of this issue is here: https://github.com/aurelia/binding/issues/50
I was thinking of handling it precisely this way. Also, I was thinking of teaching the AccessScope node about $parent. Using $global is an interesting idea as well. I will need to consider this. Regarding the $data, my inclination was towards using $this as the other issue requests. I could be persuaded either way though.
All that said, I'm a bit nervous about adding any of this until after the binding system re-work. I would like to hold off on these until after that work is done.
Ok. This is in master now and will go out in the next release. Thanks @jdanyow
One of the biggest benefits I experienced with this in angular was the easiness of adapting external libs into an existing code base. It prevented having to rewrite/refactor functions that were called from templates, because you didn't have to worry about the argument order a specific directive expected.
This could be implemented by wrapping the function passed in with one using es6 named params, in the
typeahead
view model, the select delegate could called likethis.select({$item})
, then the wrapped function would apply themyVar
variable from outside thetypeahead
's scope.<typeahead select.delegate="myCustomSelectFunc($item)"></typeahead>
and<typeahead select.delegate="myOtherCustomSelectFunc(myVar, $item)"></typeahead>
would both work correctly when called from thetypeahead
custom element with the$item
variable being supplied from thetypeahead
element andmyVar
coming from the view/view-model containing thetypeahead
Let me know if this is the wrong repo for this issue and I'll move it.