I want to change the user interface on scrolling the page, and for that i want to get the position of div element (top and bottom), how can i do this in angularjs ? In the following code how can i get the top_position?
var w=angular.element($window);
w.bind('scroll', function(){
var top_div=angular.element($('#top-div'));
// now here what function should i use ?
console.log("the top of the div having id top-div:"+**top_position**);
});
you can get the DOM element in a link function of your directive and do with it wherever you want
scope: {...},
restrict: 'AE',
controller: function() {},
link: function($scope, elem, attrs) {
var el = elem[0]; // elem - jQLite element, el - native DOM element
console.log(el.getBoundingClientRect()); // the bounding rect of the element
}