angular.js - angular directive中调用highchart报错
滿天的星座
滿天的星座 2017-05-15 16:55:01
0
2
619

在指令中掉用highchart报错了245个错,报错内容是 illegal invocation 和 digest 循环达到上限,代码如下

.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)
            })
        }
    }
})

我在chrome的控制台里把log的变量调用是没报错的,highchart动作何处触发了angular的循环

滿天的星座
滿天的星座

全部回复(2)
巴扎黑

问题出在对象上,复制下对象就可以了

PHPzhong

我觉得应该是你link里的scope.$watch()

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!