Angularjs remove()方法是不工作的IE11 [英] Angularjs remove() method is not working on IE11

查看:504
本文介绍了Angularjs remove()方法是不工作的IE11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下Angularjs remove()方法是在Firefox工作的罚款。然而,当我使用Internet Explorer 11(IE 11),它不工作。我收到错误,对象不支持属性或方法删除

以下是我的code。任何帮助,请。你甚至可以参考plunker http://plnkr.co/edit/0XtT0f?p= preVIEW ,当您使用IE11删除图表将无法正常工作。我使用angulajs 1.2.16。

VAR chartDivs = angular.element(document.querySelector('。chartsDiv'))
VAR cntChartDivs = chartDivs.length;如果(cntChartDivs){
    而(cntChartDivs大于0){
        chartDivs [cntChartDivs - 1]一个.remove();
        cntChartDivs = cntChartDivs - 1;
    }
}


解决方案

chartDivs [cntChartDivs - 1] 返回原始DOM元素。在remove()函数是在JQlite包装,所以你只需要重新包起来。

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

另外,你可以只用做删除所有的'chartDivs排行榜:

  chartDivs.remove();

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;
    }
}

解决方案

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();

这篇关于Angularjs remove()方法是不工作的IE11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆