search

Home  >  Q&A  >  body text

angular.js - Error when calling highchart in angular directive

When using highchart in the command, an error of 245 was reported. The error content was illegal invocation and digest. The loop reached the upper limit. The code is as follows

.directive('highchart',function($timeout){
    return{
        restrict:'E',
        template:'<p></p>',
        scope:{
            config:'='
        },
        link:function(scope, ele, attr) {
            var handle;
            scope.$watch('config',function(cfg){
                if(handle){
                    $timeout.cancel(handle);
                }
                handle = $timeout(function(){
                    console.log(ele.find('p'),scope.config)
                    ele.find('p').highcharts(scope.config)
                },250)
            })
        }
    }
})

No error was reported when I called the log variable in the chrome console. Where did the highchart action trigger the angular loop

滿天的星座滿天的星座2814 days ago681

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-15 16:57:01

    The problem lies in the object, just copy the object

    reply
    0
  • PHPz

    PHPz2017-05-15 16:57:01

    I think it should be scope.$watch() in your link

    reply
    0
  • Cancelreply