I'm AngularJS newbie. I want to create grid (using ng-grid) which height depends on window height ie. $('.gridStyle').height($(window).height() - 100);
I have written directive:
app.directive('resize', function($window) {
return function(scope, element) {
function applyHeight() {
scope.height = $window.innerHeight;
$('.gridStyle').height(scope.height - 100);
}
angular.element($window).bind('resize', function() {
scope.$apply(function() {
applyHeight();
});
});
applyHeight();
};
});
This works well when I resize browser window but style is not applied when site is loaded for the first time. Where can I put code to initalize height?
$timeout(applyHeight)change style but unfortunately grid is not refreshed$applyto a'resize'event is a terrible idea if you application isn't tiny.resizecan be triggered over 20-50 times per second when resizing a window. Use with care.