2015-12-30 57 views
0

我正在使用angular-gantt库,并在动态更改高度时遇到一些麻烦。当我在控制器中设置了maxHeight属性的新值时,它对视图没有影响。我认为,这样的改变应该是可能的,因为在演示应用程序中工作(Angular Gantt demo - 当点击布局 - >高度)。也许我错过了什么?欣赏任何线索。更改角甘特组件的maxHeight没有任何作用

这里是我的示例代码:

<!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> 

回答

0

我发现它工作正常,当我把最大高度属性甘特的DIV中。显然,将该变量绑定到甘特图的作用域时遇到了一些麻烦,仅依赖于选项属性。

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