angular的directive指令动态设置元素style属性

项目中,angular的directive指令可以动态的设置元素style属性,实例如下:

var app = angular.module('myApp', ['ionic']);
app.directive('scrollHeight',function($window){
  return{restrict:'AE',
    link:function(scope,element,attr){element[0].style.height=($window.innerHeight-146)+'px';}
  }
})
app.directive('scrollHeightTb',function($window){
  return{restrict:'AE',
    link:function(scope,element,attr){element[0].style.height=($window.innerHeight-40)+'px';}
  }
})

用法:

<ion-scroll class="ion-scroll" zooming="false" direction="y" style="width:100%;" scroll-height></<ion-scroll>
正在加载评论...