0

I have a directive that is getting a value passed into it from it's parent controller.

<hack-chart-controls counttime="vm.countInMinutes"></hack-chart-controls>

In the directive there are some scope values that are used to create a chart

scope.averageVbcCountPosition = { value: scope.counttime };
scope.averagePayPosition = { value: 12 };
scope.storeCountPosition = { value: 5 };

These values are used to pass to yet another child directive

<hack-annual-expenses-chart hack-employee-hourly-rate="averagePayPosition.value"
    hack-vbc-average-count-time="vbcCountTime.value"
    hack-average-count-time="averageCountPosition.value"
    hack-stores="storeCountPosition.value"
    hack-store-daily-balances="dailyBalancesCountPosition.value"
    hack-years="savingsProjectionPosition.value">

As you can see one of them depends on the passed in variable. I'm using a scope.$watch to watch when that variable changes

scope.$watch('counttime', function(value) {
    scope.counttime = value;
});

It is successfully updating as helpful from this link, but the chart doesn't update.

I tried a scope.$apply() and I get an error that a $digest() is already in progress error. What am I missing? How can I get the directive to essentially re-render the chart?

Community
  • 1
  • 1
Jon Harding
  • 4,928
  • 13
  • 51
  • 96
  • 2
    You have some spotty code here. Just paste the complete code of where `counttime` is supposed to change and where the chart (however it is implemented) is updated. Also, what is the point of doing `.$watch("counttime", ` only to assign the same value to `$scope.counttime`? – New Dev Sep 05 '15 at 03:20
  • The better question might have to do with using `ControllerAs` syntax. I'm using `var vm = this,` in the controller. But the directive can't recognize `vm`. If I could get it to recognize `vm` I wouldn't have the need to do this – Jon Harding Sep 05 '15 at 03:22

0 Answers0