I have a bunch of pages given to me by a designer that has to be integrated with my existing project in AngularJS.
The page that I have been given uses a lot of jquery . The one thing that is causing problems is the jquery's $('document').ready()
function.
Since in an angular project the page is just loaded once, most of the document.ready()
parts in any of the pages are not working. Every time a page changes, there is some code to inside this function that doesn't work.
So whichever controller in my project is supposed to have any code that work's on document.ready
I am throwing it in the controller like this :
setTimeout(function(){
$scope.$apply(function() {
var _wht=($(window).height());
var _wwt=($(window).width());
_wht=($(window).height());
_wwt=($(window).width());
if(_wht > 450){
var mcht = _wht - ($('header').height()+ $('footer').height()+50);
$('.login-page').css('height',mcht+'px');
$('.login-page').css('padding-top',((mcht - 158)/2) +'px');
}
});
});
This works very well.
But I think this counters angularJS' philosophy of separation of concerns . The controller is where you have only your business logic.
Where is the best place to throw this piece of code ?