【问题标题】:AngularJs List attribute does not work in internet explorer 11AngularJs List 属性在 Internet Explorer 11 中不起作用
【发布时间】:2016-08-10 21:14:20
【问题描述】:

我有一个正在使用的范围 find 。它在chrome 中工作,但不在Internet explorer 11 中工作 我怎样才能让它在 IE 11 中工作?

$scope.NameList= [];

$scope.addRow = function () {
    if ($scope.NameList.find(findName)) {
        $scope.error = "Already in the list";
    }
}

【问题讨论】:

标签: javascript angularjs internet-explorer-11


【解决方案1】:

Internet Explorer 不支持数组上的find 方法。您必须使用 indexOf 然后访问密钥(如果存在)。

【讨论】:

  • 但是我的列表是对象列表,在这种情况下我该如何使用 indexof?
  • @user3122648 您可以使用filter 方法过滤数组中的对象并找到您要查找的对象,或者您可以使用lodash 库中的find 方法,或者您可以下载一个IE的find方法的polyfill,可以在这里找到,例如github.com/paulmillr/es6-shim
猜你喜欢
  • 2016-10-20
  • 2019-08-12
  • 2014-08-22
  • 1970-01-01
  • 1970-01-01
  • 2015-03-22
  • 2018-01-17
  • 2017-04-02
  • 1970-01-01
相关资源
最近更新 更多