highcharts-ng使config attr成为变量

时间:2016-03-11 05:56:33

标签: javascript angularjs highcharts-ng

我使用higtcharts-ng制作一些图表,我只是写了一个名为mchart的角度指令来包装它。

有代码:

'use strict';

angular.module('MyApp')
    .directive('mchart',function(){
        return {
            templateUrl : 'scripts/directives/chart/mchart.html',
            restrict : 'E',
            replace : true,
            controller : 'mChartCtrl',
            scope:{
                'type':'@',
                'num':'@',
                'col':'@',
                'title':'@',
                'chartID':'@',
                'chartConfig':'@',
                'icon':'@'
            }
        }
    })

template代码:

<div class="col-sm-{{col}} col-md-{{col}}"> 
  <section class="panel b-a"> 
    <div class="panel-heading no-border bg-{{type}} lt"> 
      <span class="pull-right badge dk m-t-sm">{{num}}</span> 
      <span class="h4 text-lt m-t-sm m-b-sm block font-bold"><i class="fa fa-{{icon}}"></i> {{title}}</span> 
    </div> 
    <div class="panel-body"> 
      <div id="b-c" class="text-center"> 
        <div class="inline" data-bar-color="#afc5de" data-track-color="#f2f4f8" data-scale-color="false" style="width: 150px; height: 250px; line-height: 150px;">
          <highchart id="{{chartID}}" config="{{config}}"></highchart> //not working here
        </div> 
      </div>     
    </div> 
  </section> 
</div>

当我把它放在我的主页上时,我从控制台得到了一些错误:

    <mchart col="4" num="152" title="total" type="primary" icon="bug"
 chartID="chart1" config="chart1Conf"></mchart>

错误:

    Syntax Error: Token '{' invalid key at column 2 of the expression
 [{{chartConfig}}] starting at [{chartConfig}}].
{{}} attr不支持

config expr。但我不知道如何处理它

0 个答案:

没有答案