I'm looking for a way to watch changes on window inner width size change in AngularJS. I've tried this approach but it doesn't work for me:
$scope.$watch('window.innerWidth', function() {
console.log(window.innerWidth);
});
You can achieve this by using the default events of angular.element(). You don't need jQuery for this. This small snippet will work for you:
/**
* Window resize event watch
*/
angular.element($window).on('resize', function () {
console.log($window.innerWidth);
});
Don't forget to unbind the event:
/**
* Window resize unbind event
*/
angular.element($window).off('resize');