how to set dynamically height to element?

后端 未结 4 2291
眼角桃花
眼角桃花 2021-02-19 03:18

I am trying to set dynamically height to element in my demo .I will tell you issue I am taking static or constant value of height in my demo .I take 250px const

4条回答
  •  误落风尘
    2021-02-19 04:12

    You could simply achieve this by own directive which will add css dynamically

    Markup

    tell Mother name

    Directive

    .directive('setHeight', function($window){
      return{
        link: function(scope, element, attrs){
            element.css('height', $window.innerHeight/3 + 'px');
            //element.height($window.innerHeight/3);
        }
      }
    })
    

    The better solution would be you could use ng-style directive that expects the values in JSON format.

    tell Mother name

    Working Codepen

提交回复
热议问题