How can i be notified when a directive is resized? i have tried
element[0].onresize = function() {
console.log(element[0].offsetWidth + \" \" +
Here a sample code of what you need to do:
APP.directive('nvLayout', function ($window) {
return {
template: "",
restrict: 'EA',
link: function postLink(scope, element, attrs) {
scope.onResizeFunction = function() {
scope.windowHeight = $window.innerHeight;
scope.windowWidth = $window.innerWidth;
console.log(scope.windowHeight+"-"+scope.windowWidth)
};
// Call to the function when the page is first loaded
scope.onResizeFunction();
angular.element($window).bind('resize', function() {
scope.onResizeFunction();
scope.$apply();
});
}
};
});