I'm working in implementing a responsive pagination component for angularjs through a custom directive. The idea is for the pager to show fewer pages for small screens and more pages for large screens so if it's showing 20 pages on my desktop and I resize the browser window (make it very small), the component should adjust and show fewer pages.
The way I want to do this is by listening to the resize event on the window object and check the width when there's a change. Depending on what the width is, I want to update the directive's controller list of pages so it shows fewer pages. I have been trying this on the directive's link:
$(window).resize(function(){
var width = $(window).width();
console.log(width);
if (width > 600) {
paginationCtrl.message='hello';
maxSize = 3;
console.log("here");
}
else{
paginationCtrl.message='bye';
}
console.debug(paginationCtrl);
}
);
The problem is, I don't see the message change on the page when I change the screen size. I'm thinking maybe link is not the best place to do this. I have a plunkr with the code here: http://plnkr.co/edit/eIj2HbJluoleBk44Knfe?p=preview