这是描述此问题的小提琴,第二个节点应该有4个值,但只显示1:
https://jsfiddle.net/mbaranski/akcz3569/
我有一个角度指令:
var OrgChartDirective = function() {
return {
restrict: 'AE',
scope: {
source : '=',
},
link: function(scope, element, attrs) {
var target = $(element);
var source = $('#' + scope.source);
var options = {
container : target,
};
console.log("Drawing org chart at :");
console.log(element);
console.log("Source is " + scope.source);
source.orgChart(options);
}
}
};
这将根据我在页面上的嵌套UL绘制组织结构图。适用于静态列表,但如果我使用角度ng-repeat绘制列表,它不显示列表,它只显示{{whatever}}
文本。如何使指令使用渲染数据而不是原始模板数据?
答案 0 :(得分:1)
使用$timeout
让ng-repeat渲染。见这里:https://jsfiddle.net/akcz3569/7/
$timeout(function() {
source.orgChart(options);
});