更改 angular-gantt 组件的 maxHeight 无效

Changing maxHeight of angular-gantt component has no effect

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

这是我的示例代码:

<!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 属性放入甘特图的 div 中时它工作正常。显然,将该变量绑定到甘特图的范围时遇到了一些麻烦,仅依赖于选项属性。

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