我的应用程序代码中有一个编译指令,并且依赖于编译我的代码在这里有一个指令:
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>");
但是树形图不起作用