Angularjs - 数据更改时刷新`d3js`图表

时间:2015-12-27 23:13:15

标签: javascript angularjs d3.js angularjs-directive

我为directive图表创建了d3js

html:
<donuts-chart chart-data="mydonuts" ></donuts-chart>

directive:
.directive('donutsChart', function ($parse) {
var donutobject = {
    restrict: 'E',
    replace: false, 
    scope: {data: '=chartData'},
    link: function (scope, element, attrs) {

      scope.$watch('data', function(newVals, oldVals) {
        console.log('there is new data');
      }, true);

          };
    return donutobject;
   })

我添加scope.$watch只是为了测试数据是否正在更新。但它没有用。我怎样才能让它发挥作用?每当有新数据时我都需要更新图表。

0 个答案:

没有答案