2.5.16
https://jsfiddle.net/4begnsym/5/
I would expect that I can use data from the slot-scope as parameters in custom directives.
Data from slot-scope is undefined in the custom directive.
child-cmp was rendered under the context of the root instance, rather than parent-cmp, in your case, you can use vnode.parent.componentInstance to refer to the parent component, like https://jsfiddle.net/4begnsym/6/
@javoski thank you for your response, but did you see that I use slot-scope?
Please reopen or explain further why I have access to someMethod in @click but not in the directive?
In my opinion, I should have access to someMethod passed into the component via the slot-scope.
Please reopen or explain further why I have access to someMethod in @click but not in the directive?
I'm not sure if I got your point clearly, you actually can access to someMethod in the directive, according to my tests, to invoke the function someMethod directly, you can just do binding.value() - https://jsfiddle.net/4begnsym/7/.
@maoberlehner your way can't work because the someMethod method is defined in the parent-comp, but v-node.context is the main Vue instance - because the directive was evaluated in the scope of the main app's template.
So everything's correct here.
@javoski @LinusBorg Oh my... I'm sorry. Idk where I copy pasted the custom directive snippet – my fault to not look up how to access the value the correct way.
I apologize for the trouble.
Most helpful comment
I'm not sure if I got your point clearly, you actually can access to
someMethodin the directive, according to my tests, to invoke the functionsomeMethoddirectly, you can just dobinding.value()- https://jsfiddle.net/4begnsym/7/.