#custom structural directive - help
6 messages · Page 1 of 1 (latest)
routerLinkActive already has such an output (isActiveChange). No need for an additional directive. https://angular.io/api/router/RouterLinkActive
BTW, such a directive wouldn't be a structural one
I wanna use the output of the routerLinkActive directive to call a function from the parent component in case an element isActive is true. The problem is that I need to do this for dozens of elements, so I thought that a custom directive would be a more elegant solution. I was reading about host directives and how you can compose directives with it. In theory it sounds like what I should be doing but if I use RouterLinkActive as host directive in my custom one, I don't know how to access its isActive property.
You inject it into your own directive.
Thanks, I added routerLinkActive to my directive constructor and can inspect the values in ngOnInit but I am trying to call a callback function inside no changes but nothing happens. How can I react to changes to isActive inside my custom directive?