For a long time, I relied on jQuery to create sticky footers for my websites. But now that I've switched to AngularJS, I no longer see the need for jQuery. Unfortunately, I'm facing challenges as my usual sticky footer code doesn't work due to $ being undefined.
HTML:
<h1>Basic plunk!</h1>
<p>If the header above is red, then you know Plunker is working!</p>
<p>The header above should slide right, indicating that jQuery is up and running.</p>
<!-- Put your html here! -->
<div id="page">
1
<br>2
<br>3
<br>4
<br>
</div>
<br>
<footer id="colophon">My footer</footer>
JS:
<script type="text/javascript">
$(document).ready(function() {
var bodyHeight = $("body").height();
var vwptHeight = $(window).height();
if (vwptHeight > bodyHeight) {
$("footer#colophon").css("position","absolute").css("bottom",0);
}
});
</script>
Is there a way to achieve the same functionality in an Angular-friendly manner?
Check out this plunker: http://plnkr.co/edit/k1EZqwpdXbKhODW4FyeF?p=preview