Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有一个编译指令和两个指令_Javascript_Angularjs_Directive_Angular Directive - Fatal编程技术网

Javascript 有一个编译指令和两个指令

Javascript 有一个编译指令和两个指令,javascript,angularjs,directive,angular-directive,Javascript,Angularjs,Directive,Angular Directive,我的应用程序代码中有一个compile指令,有两个指令取决于compile我的代码在这里: app.directive('compile', ['$compile', function ($compile) { return function(scope, element, attrs) { var ensureCompileRunsOnce = scope.$watch( function(scope) {

我的应用程序代码中有一个compile指令,有两个指令取决于compile我的代码在这里:

app.directive('compile', ['$compile', function ($compile) {
      return function(scope, element, attrs) {
          var ensureCompileRunsOnce = scope.$watch(
            function(scope) {
               // watch the 'compile' expression for changes
              return scope.$eval(attrs.compile);
            },
            function(value) {

              element.html(value);

              $compile(element.contents())(scope);
             ensureCompileRunsOnce();
            }
        );
    };
}]);
这是我的两个指示

app.directive('heatMap',['$compile',function($compile){

     return {
        // Restrict it to be an attribute in this case
        restrict: 'A',
        // responsible for registering DOM listeners as well as updating the DOM
        link: function(scope, element, attrs) {             
            $(element).treefy(scope.$eval(attrs.heatMap));

        }
    };


}]);

app.directive('basicLine',['$compile',function($compile){

     return {
        // Restrict it to be an attribute in this case
        restrict: 'A',
        // responsible for registering DOM listeners as well as updating the DOM
        link: function(scope, element, attrs) {             
            $(element).highcharts(scope.$eval(attrs.basicLine));                    
        }
    };


}]);
basicLine指令可以治愈,但另一个指令在我出错的地方不起作用?我在html中使用
$sce.trustAsHtml(“”
$sce.trustAsHtml(“”)在我的javascript代码中

但是treemap不起作用

什么是“不起作用”呢?有错误吗?两个指令依赖于编译指令是什么意思?至少从代码中,我看不到依赖性。什么是
$eval(“配置”)
返回?清楚地解释什么不起作用。如果需要,在plunker中提供代码。明确你想要达到的目标。不显示图表两个元素都必须显示图表,但其中一个只是工作,基本线工作,另一个不工作,无返回指令可能不会调用heat Map提供plunker,人们可以尝试帮助您调试它。这是大项目的一部分,我不能制作plunker。您应该减少代码,以便自己重现问题。事实上,当你尝试这样做时,你很可能会自己发现问题。从您提供的代码来看,不清楚发生了什么,更不用说为什么它不工作了