angular.js - Error when calling highchart in angular directive
滿天的星座
滿天的星座 2017-05-15 16:55:01
0
2
657

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

滿天的星座
滿天的星座

reply all(2)
巴扎黑

The problem lies in the object, just copy the object

PHPzhong

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template