How to update sideMenu width?


#1

Hi, I’m trying to set sideMenu’s width via a $scope variable.

index.html’s body

<ion-side-menus>
  <ion-side-menu-content>
    <!-- content -->
  </ion-side-menu-content>
  <ion-side-menu side="left" width="{{width}}" expose-aside-when="(orientation: landscape) and (device-width:414px), (min-width:768px)">
    <!-- side content -->
  </ion-side-menu>
</ion-side-menus>

app.js’s controller

app.controller('controller', function ($scope, $window) {
  $scope.width = $window.innerWidth*0.4;
}]);

It works but now I would update the value on window resizing.
Here’s a codepen:

I’m not familiar with $scope.$watch(), $scope.$apply() and ionic.on().
Any help? Thanks in advance.


#2

Did you manage to do this? I tried

  $scope.$watch(function(){
       return $window.innerWidth;
    }, function(value) {
       console.log("inner", value);
       $scope.notificationWidth = value * 0.8;
   });

but it doesn’t work. (Either the watch function isn’t even called or if it is the width of side-menu isn’t changed)