0

I am trying with the first directive I ever create, but I received the follow errors.

var directives = angular.module('testApp', []);

directives.directive('ratings', function () {
        return {
            restrict: 'A',
            link: function (scope, elem, attrs) {
                console.log("Recognized the ratings directive usage");
            }
        };
});

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!

I put the file under directives subfolders , and here is my folder structure.

directives
controllers
services

Anything wrong with my code?

Adam Lee
  • 24,710
  • 51
  • 156
  • 236
  • That directive isn't changing anything in the scope that would cause the digest to run again so error and directive shown are not related. It would seem you over simplified your example code or problem is elsewhere – charlietfl Jan 15 '16 at 16:15
  • Post a **complete** minimal example reproducing the problem. We have no idea of what the stack trace is, of how you used the directive, of what other components are involved, etc. – JB Nizet Jan 15 '16 at 16:16
  • It is probably something initialization on the html side as explained here: http://stackoverflow.com/questions/14376879/error-10-digest-iterations-reached-aborting-with-dynamic-sortby-predicate Try posting a complete code sample of your problem – Erwin Jan 15 '16 at 16:17
  • agree with @charlietfl. this code is not changing anything in the code then how this error can come? might b you are refreshing scope manually or out side from that scope? – Umer Hayyat Jan 15 '16 at 16:24
  • There is no error in the above code but might be in the other files. – bvakiti Jan 15 '16 at 16:28

0 Answers0