I am working on 2 components using Angular 1.5.
I want to access the parent from the child, and I managed to do it using :
require: {
parent: '^parentCmp'
}
The thing is, I would like to do the same, but without "fixing" the parent as "parentCmp", since it won't always be this component I'll have as a parent.
Thanks.
You should not do it :) But if you have to, you can pass it as regular binding
. Child component:
bindings: {
parent: '<'
}
And in parent template (I presume that you use $ctrl
alias for controller
, if it's not true use name you provide):
<child-component
parent="$ctrl"
>
</child-component>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With