我刚刚实现了 ag-grid,但发现在使用带有角度编译模板的 cellTemplates 时 IE9 会崩溃。
你们中是否有人遇到过这种情况并可能找到了解决方法?
如何重现:
使用 IE 前往此处 ( http://www.ag-grid.com/angular-grid-cell-template/index.php ),然后从 DevTools 中选择 IE9。
由于角度编译的模板,它会崩溃。不知道我能做些什么。
(我还在 GitHub 上打开了一个问题:https ://github.com/ceolter/ag-grid/issues/521 )
编辑:
调试它,有一个无限循环,因为从一种方法更新数组,以某种方式对另一种方法不可见......
无限循环是:getTemplate,(排队等待,直到调用结束),调用结束,模板添加到缓存,运行回调,回调在模板缓存中没有看到模板,创建另一个回调,将其添加到队列中,等等上。(来自下面的 ag-grid 的代码)。
// returns the template if it is loaded, or null if it is not loaded
// but will call the callback when it is loaded
TemplateService.prototype.getTemplate = function (url, callback) {
var templateFromCache = this.templateCache[url];
if (templateFromCache) {
return templateFromCache;
}
var callbackList = this.waitingCallbacks[url];
var that = this;
if (!callbackList) {
// first time this was called, so need a new list for callbacks
callbackList = [];
this.waitingCallbacks[url] = callbackList;
// and also need to do the http request
var client = new XMLHttpRequest();
client.onload = function () {
that.handleHttpResult(this, url);
};
client.open("GET", url);
client.send();
}
// add this callback
if (callback) {
callbackList.push(callback);
}
// caller needs to wait for template to load, so return null
return null;
};
TemplateService.prototype.handleHttpResult = function (httpResult, url) {
if (httpResult.status !== 200 || httpResult.response === null) {
console.warn('Unable to get template error ' + httpResult.status + ' - ' + url);
return;
}
// response success, so process it
this.templateCache[url] = httpResult.response;
// inform all listeners that this is now in the cache
var callbacks = this.waitingCallbacks[url];
for (var i = 0; i < callbacks.length; i++) {
var callback = callbacks[i];
// we could pass the callback the response, however we know the client of this code
// is the cell renderer, and it passes the 'cellRefresh' method in as the callback
// which doesn't take any parameters.
callback();
}
if (this.$scope) {
var that = this;
setTimeout(function () {
that.$scope.$apply();
}, 0);
}
};
return TemplateService;
})();