Angularjs自定义指令计算浏览器高度

<!DOCTYPE html>
<html ng-app="app">
<head>
<title>柳絮飞祭奠</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="/APP-INF/plugins/angular/angular.js"></script>
</head>
<body> <div lx-ui-auto="" height-remove="10" style="background-color: red;"></div>
</body>
<script type="text/javascript">
var app=angular.module("app",[]); /**
* height-remove 设置窗口高度需要移除的高度值,如移除顶部导航高度50
* height-tag 设置是按height还是min-height设置高度值,height才会出现滚动条。
*/
app.directive('lxUiAuto', function($window) {
return {
restrict : 'A',
scope : {},
link : function($scope, $element, $attrs) {
if($attrs.heightTag==undefined){
$element.css("min-height", ($window.innerHeight-$attrs.heightRemove) + 'px');
}else{
$element.css($attrs.heightTag, ($window.innerHeight-$attrs.heightRemove) + 'px');
}
}
};
});
</script>
</html>

效果:



Angularjs自定义指令计算浏览器高度

上一篇:C# 过滤特殊字符


下一篇:CODING Pages 服务全面升级,更快更稳更可靠!