Angularjs remove() method is not working on IE11

前提是你 提交于 2019-12-24 02:42:48

问题


The following Angularjs remove() method is working fine in firefox. However when I use Internet Explorer 11 (IE 11), it is not working. I am getting the error, Object doesn't support property or method 'remove'

The following is my code. Any help please. You can even refer the plunker http://plnkr.co/edit/0XtT0f?p=preview, when you use IE11 'Remove Chart' won't function. I am using angulajs 1.2.16.

var chartDivs = angular.element(document.querySelector('.chartsDiv'))
var cntChartDivs = chartDivs.length;

if (cntChartDivs) {
    while (cntChartDivs > 0) {
        chartDivs[cntChartDivs - 1].remove();
        cntChartDivs = cntChartDivs - 1;
    }
}

回答1:


Doing chartDivs[cntChartDivs - 1] returns the raw DOM element. the remove() function is on the JQlite wrapper, so you just need to rewrap it.

angular.element(chartDivs[cntChartDivs - 1]).remove();

Alternatively you could just remove all of the charts in 'chartDivs' by doing:

chartDivs.remove();


来源:https://stackoverflow.com/questions/27309825/angularjs-remove-method-is-not-working-on-ie11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!