angular.js - How to dynamically set the minimum height in angular
phpcn_u1582
phpcn_u1582 2017-05-15 16:58:17
0
1
783

html structure:

<body>
  <p id="header"></p>
  <p id="article"></p>
  <p id="footer"></p>
</body>

What I want to achieve is: dynamically set a min-height for the article: 可见区域高度-header高度-footer高度 to avoid the footer appearing in the middle of the page.

I am using angularjs and do not plan to introduce jquery, so naturally I cannot use $(document).ready().

The problems I encountered are:

  1. Unable to be implemented: Wait until the page is loaded and trigger the function to dynamically set the height. In the following cases, the functions are not executed (the same is true when window is replaced with document):

    angular.element($window).ready(function() {});
    angular.element($window).on('load', function() {});
    angular.element($window).bind('load', function() {});
    angular.element($window).onload(function() {});
    $window.onload = function() {};
    $scope.$on('$viewcontentloaded', function() {});
    
  2. I don’t know if it is better to put this code in the directive or in the Controller, or somewhere else.

  3. Use css to directly set the minimum height. If it is hard-coded (for example: min-height: 400px), scroll bars will appear when the screen is small.

Or just don’t use these methods. What I did was wrong. Please give me your advice. Thank you very much.

phpcn_u1582
phpcn_u1582

reply all(1)
给我你的怀抱

Write onedirective吧。处理比较方便,虽然其实css的flex布局也可以解决这个问题。但根据你的疑问,还是先回答你通过angularHow to write it? Go directly to plunk.

plunkYou don’t need to be taught how to watch it (requires scientific Internet access)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template