2013-11-21 3 views
1

jquery handsontable을 true 각도로로드하는 지시문을 만듭니다. 그러나 이것은 handsontable의 첫 번째 로딩에 대한 진정한 방법입니다. 마우스 클릭 후 테이블 데이터를 변경해야하는 경우 어떻게해야합니까?마우스가 클릭으로 핸디 터블 loadData를 트리거하기위한 올바른 방법

var gmApp = angular.module('gmApp', ['gmServices']); 
gmApp.directive('myChart', function() { 
    return { 
     restrict: 'A', 
     link: function(scope, element, attrs) { 
      $(element).handsontable(scope.$eval(attrs.myChart)); 
     } 
    }; 
}); 

또한 showVariable을 발사 목록() 함수를 생성

<ul> 
     <li ng-repeat="variable in list" ng-click="showVariable(variable.id)">{{variable.name}}</li> 
</ul> 

내 컨트롤러에서이 기능 화재 loadData :

$scope.showVariable = function(id) { 
    $('#myChart').handsontable('loadData', $scope.data[id]); 
}; 

그러나이 컨트롤러 내부의 DOM을 변경하는 것 같다 그리고 진실 된 각도 방법이 아닙니다. handsontable ('loadData')을 수행하는 올바른 각도 방법은 무엇입니까?

답변

2

하여 지침의 link 기능으로 이동 showVariable :

link: function(scope, element, attrs) { 
     $(element).handsontable(scope.$eval(attrs.myChart)); 

     scope.showVariable = function(id) { 
      $('#myChart').handsontable('loadData', $scope.data[id]); 
     }; 
    }