Window orientationchange event in Angular

tdhulster picture tdhulster · Apr 10, 2014 · Viewed 17.1k times · Source

Is there a way to call the orientationchange event inside an AngularJS directive?

I'm currently working with angular-masonry and I'm trying to update/refresh masonry when the orientation of the mobile device changes.

I've found this but I'm wondering how to do this with the $window service inside Angular

window.addEventListener("orientationchange", function() {
  // Announce the new orientation number
  console.log(window.orientation);
}, false);

Answer

user1325394 picture user1325394 · Jun 6, 2014
angular.element($window).bind('orientationchange', function () {

});