Reputation: 397
I am creating a webpage with three sections and when I click a button I am changing the width of each sections based on screen width. After I click the button if I resize the screen the three sections adjust based on current screen size. I am trying to get notification when screen size changing. Here is my html code.
<div class="minbutton" ng-click="minimize()">
<div ng-if="toggles">
<i class="fa fa-angle-double-left"></i>
</div>
<div ng-if="!toggles">
<i class="fa fa-angle-double-right"></i>
</div>
</div>
Here is my controller code.
$scope.minimize= function(){
var width =$(window).width();
if($scope.toggles=== true){
$(".section1").attr('style','width:14%');
$(".section2").attr('style','width:26%');
$(".section2").attr('style','left:14%');
$(".section3").attr('style','left:40%');
$(".section3").attr('style','width:60%')
$scope.toggles = true;
} else {
section1Left = 56;
leftSection = width - 56;
section2Width=Math.round( leftSection * 0.30);
section3Left = section2Width + 56;
section3Width = Math.round(leftSection *0.70);
$(".section1").css("cssText","width:56px !important;");
$('.section2').css({left:section1Left,width:section2Width});
$('.section3').css({left:section3Left,width:section3Width}):
$scope.toggles = false;
}
};
when I click minimize I am fixing first section and adjusting rest of the width for 2 sections.when the screen resizing I want to notify and get the current screen width and I am trying adjust the sections with the current width. How do I notify when screen resizing?
Upvotes: 0
Views: 39
Reputation: 5998
Angular is not the answer. This is no special tools in angular for this. But you still can use JS or JQuery, like this Jquery resize
Upvotes: 1