更改角度gantt组件的maxHeight没有任何效果

Changing maxHeight of angular-gantt component has no effect

本文关键字:maxHeight 任何效 组件 gantt      更新时间:2023-09-26

我使用的是angular gantt库,在动态更改高度时遇到了一些问题。当我在控制器中设置maxHeight属性的新值时,它对视图没有影响。我认为,这样的改变应该是可能的,因为它在演示应用程序中工作(Angular Gantt演示-单击Layout->Height时)。也许我错过了什么?感谢任何线索。

这是我的示例代码:

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="angular-gantt.css" />
    <script src="angular.js"></script>
    <script src="moment.js"></script>
    <script src="angular-moment.js"></script>
    <script src="angular-gantt.js"></script>
  </head>
  <body ng-app="myApp">
    <script>
        var myApp = angular.module('myApp', ['gantt']);
        myApp.controller('Ctrl', ['$scope','$window', function($scope, $window){
          $scope.cutSomeHeight = function() {
            $scope.options.maxHeight -= 50;
          }
          $scope.options = {
            maxHeight: 500,
            data: [],
            viewScale: "1 month",
            columnWidth: 100
          }
          for (var i=0; i<100; i++){
            $scope.options.data.push({name: 'Task' + i, tasks: [{name: i, from: moment("2015-01-01","YYYY-MM-DD").add(i % 12, 'months'), to: moment("2015-06-01","YYYY-MM-DD").add(i % 12, 'months')}]})
          }
       }]);
    </script>
    <div ng-controller="Ctrl">
      <button ng-click="cutSomeHeight()">Cut</button>
      <div gantt options="options"></div>
    </div>
  </body>
</html>

我发现当我把max-height属性放在gantt的div中时,它工作得很好。显然,它在将该变量绑定到gantt的作用域时遇到了一些问题,只依赖于options属性。

<div gantt options="options" max-height="options.maxHeight"></div>