如何根据当前窗口高度动态设置marginTop?
E.g。
$scope.chartConfig = {
options: {
chart: {
type: 'solidgauge',
// set to -50 if window height is 700px...
// set to -20 if window height is 500px...
marginTop: -50
}
}
}
答案 0 :(得分:1)
这是我解决它的方式:
function ChartController($scope, $window) {
$scope.chartConfig = {
options: {
chart: {
type: 'solidgauge',
// set to -50 if window height is 700px...
// set to -20 if window height is 500px...
marginTop: 0
}
}
}
if ($window.innerHeight >= 568 && $window.innerHeight <= 639) {
$scope.chartConfig.options.chart.marginTop = -95;
}
}