I'm working in AngularJS and trying to encapsulate things into directives. I'm needing to use jQuery to implement some scrolling functionality. I want a parent div's child button to remain fixed at the bottom of the screen when the div is only partially visible. Here's a jsfiddle of what I'm wanting to put into Angular.
Here's the HTML (also viewable in jsfiddle):
<div class="spacer">spacer div - scroll down</div>
<div id="parent">
parent div content
<div id="childContainer">
<button id="child" style="">Test Button</button>
</div>
</div>
<div class="spacer">spacer div - scroll up</div>
I'm trying to avoid using ID selectors in Angular (I think they're bad for directives). So far I've done this by using attribute directives on elements and storing the element in the directive's link function. This works fine when the directive doesn't need to write HTML of its own. If I write HTML in the attribute directive, it overrides the parent's HTML.
In this case, however, I'm needing the attribute directive to contain a button. If I wrote the HTML for the button, it would delete the HTML for my parent.
So the problem is that I can't use an attribute directive to get the parent element in Angular.
I'm probably going about this all the wrong way, but I'm hoping someone with more Angular experience can understand my thought process and point me in the right direction?
parentsUntilmethod to find the parent. The rest I didn't understand but you will know what to do from there I guess.$(element).parent()