有一个带有两个指令的编译指令

时间:2014-12-03 06:59:38

标签: javascript angularjs directive angular-directive

我的应用程序代码中有一个编译指令,并且依赖于编译我的代码在这里有一个指令:

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中使用并在我的javascript代码中使用$sce.trustAsHtml("<div id='treemap' heat-map='config'></div>")$sce.trustAsHtml("<div id="basic" basic-Line='config'></div>"); 但是树形图不起作用

0 个答案:

没有答案
相关问题