在ng-repeat指令

时间:2016-10-17 12:36:11

标签: javascript html angularjs angularjs-directive angularjs-ng-repeat

我有以下设置:

            <div class="col-md-12" ng-repeat="(professorKey, oProfessor) in JsonTeachers">
                <div class="dropzone box teacher-chart">
                    <div class="col-md-5 col-md-offset-1 title">
                        <h2>{{oProfessor.id_professor}}</h2>
                    </div>
                    <h3>DROPZONE</h3>
                    <app-graph align="center">
                    </app-graph>
                </div>
            </div>

代码第一次正确执行。 当我们改变JsonTeachers的值时(我们添加一个新的对象/教师),问题出现了。在这种情况下,ng-repeat将再次执行,但指令&#34;&#34;惯于。

主要问题是:在ng-repeat指令

中重新执行指令

如果需要这里是指令的代码(它只是绘制图形)。但它永远不会被执行(再次)

return { 
    restrict: 'E', 
    scope: { 
    professor: '=',
    },
    controller: 'mainController',
    templateUrl: '/js/directives/appGraph.html',
    link: function (scope, element) {
       scope.oMaestros=jsonConversion.getJsonGraph();
       scope.Arrayprof=[];
       for ( var professor in scope.oMaestros){
           var graph = {};
           graph = scope.comunOptions;
           graph.chart.renderTo = professor + "_id";
           graph.yAxis.title = professor;
           graph.series = scope.oMaestros[professor].series.slice(0);

           eval('scope. ' + professor + '_id =new Highcharts.chart(professor + "_id",graph);')
           scope.Arrayprof[i]=professor;
           delete graph;
       }// end for
    }
}//end return

0 个答案:

没有答案