0

I have this code in my HTML:

                <uib-pagination
                   previous-text="{{previousText}}" 
                   next-text="{{nextText}}"
                </uib-pagination>

My angular translate is being $watch:

        $translate(['PREVIOUS', 'NEXT']).then(function (translations) {
            $scope.previousText = translations.PREVIOUS;
            $scope.nextText = translations.NEXT;
        });

but then I get this error:

enter image description here

I'll try to solve it with this tutorial :

  1. https://docs.angularjs.org/error/$rootScope/infdig

  2. How to Troubleshoot Angular "10 $digest() iterations reached" Error

but I'm still getting same errors. I try to troubleshoot by removing some code and this is my new code but I'm still getting same errors.

        $scope.$watch(function()
        {
            $translate().then(function () {

            });
        }, true);  

I am clueless right now. How can I solve this problem? by the way, the pagination did managed to translated but I've seen this error in my console and it's not neat. Thanks in advance.

Community
  • 1
  • 1
sg552
  • 1,521
  • 6
  • 32
  • 59
  • did you check `$scope.$$phase()`? – Ramesh Rajendran Jan 17 '17 at 09:43
  • $watch callback is called every cycle. And `$translate().then` triggers another digest (that's how $q promises work). This is infinite digest. `$translate()` calls can be limited to language changes or whatever. Why is `$translate` and not `translate` filter used, btw? – Estus Flask Jan 17 '17 at 10:38
  • Quite often infdig means infdig = after running watches something in scope changes, so watches run again and something changes again and so on... i.e. watching function that return no value makes no sence to me – Petr Averyanov Jan 17 '17 at 10:53
  • @estus I did use `translate` but unfortunately for pagination it failed to translate dynamically. That's why I had to use `$translate` – sg552 Jan 17 '17 at 12:42
  • It should work with filter if you're doing everything right, I would suggest to do this. It is clear why you're doing this in $scope.$watch the way you do, especially because it is expected that it will cause infinite digest. – Estus Flask Jan 17 '17 at 13:43

0 Answers0