我已将 visjs 时间线包装成角度指令。当我调用$route.reload()外部控制器时,时间线消失了。页面重新加载完成后,指令仍然具有对原始时间线对象的引用,并且 dom 元素似乎没有改变。
有谁知道什么会导致它消失?
我创建了一个 plunkr,但我不知道如何在 plunker 中重新加载路由,因为这会改变 url。
http://plnkr.co/edit/hwShQ2iYR7TOcILSBcEY?p=preview
function timelineViewer() {
var timeline;
return {
restrict: 'E',
replace: true,
scope: {
data: '='
},
controller: function($scope) {
var items = new vis.DataSet();
var container = document.getElementById('vis-timeline');
var options = {
height: 100,
width: 600,
zoomMin: 1000 * 60 * 2,
zoomMax: 1000 * 60 * 20
};
items.clear();
items.add($scope.data);
timeline = new vis.Timeline(container, items, options);
console.log('Reloading directive ...')
},
template: '<div id="vis-timeline"></div>'
};
}