【问题标题】:Changing maxHeight of angular-gantt component has no effect更改 angular-gantt 组件的 maxHeight 无效
【发布时间】:2015-12-30 09:29:51
【问题描述】:

我正在使用 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>

【问题讨论】:

    标签: javascript angularjs gantt-chart


    【解决方案1】:

    我发现当我将 max-height 属性放入甘特图的 div 时它工作正常。显然,将该变量绑定到甘特图的范围时遇到了一些问题,仅依赖于 options 属性。

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

    【讨论】:

      猜你喜欢
      • 2015-10-10
      • 1970-01-01
      • 2018-12-23
      • 2019-02-09
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 2017-12-09
      • 1970-01-01
      相关资源
      最近更新 更多