Angularjs resize region variable to window size

I am trying to change the scope variable: $scope.tabevery time the window is resized and $scope.tab == 'more'.

the code:

$scope.closeMoreTab = function() {
    if($scope.tab == 'more')
        $scope.tab = 'extras';
};

angular.element($window).bind('resize', function() {
    $scope.closeMoreTab();
});

Well, it really calls $scope.closeMoreTab(), and it really changes the variable $scope.tab, but in fact it does not change anything in the view.

I tried:

console.log($scope);

To check the variable taband it will really change to "extra", but when I do this:

<div>{{ tab }}</div>

It shows me that the current tab variable is still "larger"

Please, help. I am stuck with this as 1 hour and don’t know why this is happening or what to do.

Many thanks

+4
2

$scope.closeMoreTab(); $scope.$apply, , :

angular.element($window).bind('resize', function() {
    $scope.$apply(function() {
        $scope.closeMoreTab();
    });
});
+6

$watch, , , $apply , $apply $digest.

-1

All Articles