Javascript IE不更新下拉选择显示

Javascript IE不更新下拉选择显示,javascript,angularjs,internet-explorer-11,Javascript,Angularjs,Internet Explorer 11,我有3个下拉列表,其中绑定了角度范围数组。当我更新模型时,一个下拉列表显示所选的值,但另两个下拉列表不更新显示。实际上,该项目已被选中,但下拉列表显示的是一个空白项目。我正在使用AngularJSV1.2.2和IE11 在铬合金中,它工作得很好。仅当将select ng选项与过滤器一起使用时,才会出现选择问题 //$scope.Areas is bound to dropdown and $scope.A.Area is the ng-model to Area dropdown, workin

我有3个下拉列表,其中绑定了角度范围数组。当我更新模型时,一个下拉列表显示所选的值,但另两个下拉列表不更新显示。实际上,该项目已被选中,但下拉列表显示的是一个空白项目。我正在使用AngularJSV1.2.2和IE11 在铬合金中,它工作得很好。仅当将select ng选项与过滤器一起使用时,才会出现选择问题

//$scope.Areas is bound to dropdown and $scope.A.Area is the ng-model to Area dropdown, working fine $scope.A.Area = $scope.Areas.firstOrDefault(function (x) { return x.AreaID === $scope.RespondentAreaID; }); //$scope.Regions is bound to Region dropdown and $scope.A.Region is the ng-model to Region dropdown, not updating the dropdown diaplay in IE $scope.A.Region = $scope.Regions.firstOrDefault(function (x) { return x.RegionID === $scope.A.RespondentRegionID; }); // There is no countries list in the scope like $scope.Areas or $scope.Regions // Countries are stored as navigational property with Region, so to populate the // countries use the selected Region.Countries, not working in IE if ((($scope.A.Region || {}).Countries || []).length) { $scope.A.Country = $scope.A.Region.Countries.firstOrDefault(function (x) { return x.CountryID === $scope.RespondentCountryID; }); //$scope.Area绑定到下拉列表,$scope.A.Area是ng模型到区域的下拉列表,工作正常 $scope.A.Area=$scope.Areas.firstOrDefault(函数(x){ 返回x.AreaID==$scope.RespondentAreaID; }); //$scope.Regions绑定到区域下拉列表,$scope.A.Region是ng模型到区域下拉列表,不更新IE中的下拉列表 $scope.A.Region=$scope.Regions.firstOrDefault(函数(x){ 返回x.RegionID==$scope.A.RespondentRegionID; }); //该范围中没有类似于$scope.Areas或$scope.Regions的国家/地区列表 //国家/地区存储为带有区域的导航属性,以便填充 //国家/地区使用所选区域。国家/地区,不在IE中工作 if(($scope.A.Region | |{}).Countries | |[])长度){ $scope.A.Country=$scope.A.Region.Countries.firstOrDefault(函数(x){ 返回x.CountryID==$scope.RespondentCountryID; });
在angular.js中selectDirective的render函数的以下位置(用粗体标记)添加几行代码对我来说效果很好。我正在寻找除了修补angularJS或下面给出的forEach之外,是否还有其他可能的解决方案

            if (existingOption.label !== option.label) {
              lastElement.text(existingOption.label = option.label);
              **lastElement.attr('label', existingOption.label);**
            }

问题在于,如果IE中标签为空,则HTMLOptionElement的标签属性与文本属性不同

这可以通过在屏幕加载后添加以下代码来进行验证,并查看FF和IE的web控制台以查看差异。如果取消对标签设置为文本的最后一行的注释,则效果良好。或者,也可以按上述方法修补angular.js

// This is an IE fix for not updating the section of dropdowns which has ng-options with filters
angular.forEach($("select"), function (currSelect) {
    console.log("1.text ", currSelect.options[currSelect.selectedIndex].text);
    console.log("1.label ", currSelect.options[currSelect.selectedIndex].label);
    //console.log("1.innerHTML ", currSelect.options[currSelect.selectedIndex].innerHTML);
    //console.log("1.textContent ", currSelect.options[currSelect.selectedIndex].textContent);
    //console.log("1.cN.data ", currSelect.options[currSelect.selectedIndex].childNodes[0].data);
    //console.log("1.cN.nodeValue ", currSelect.options[currSelect.selectedIndex].childNodes[0].nodeValue);
    //console.log("1.cN.textContent ", currSelect.options[currSelect.selectedIndex].childNodes[0].textContent);
    //console.log("1.cN.wholeText ", currSelect.options[currSelect.selectedIndex].childNodes[0].wholeText);
    //console.log("1. ", currSelect.options[currSelect.selectedIndex], "\n");

    //currSelect.options[currSelect.selectedIndex].label = "xyz";
    //currSelect.options[currSelect.selectedIndex].label = currSelect.options[currSelect.selectedIndex].text;
});

任何一组选择下拉列表都会出现完全相同的问题。如果您再次尝试在下拉列表中选择值,似乎会起作用。例如:在一组3个日期下拉列表中选择月份,尝试选择日期,但它只显示选择下拉列表中的第一个选项。再次尝试选择一个值,它会起作用。Angular 1.2.0-rc.2与IE11一起使用。接受它吧你在最近几天没有找到解决方案?谢谢areynolds,我找到了一个解决方案,如果我们更改下拉列表的文本,它将选择该值。一旦设置了下拉列表值,在stackoverflow中找到该解决方案,但不记得链接//这是一个IE修复程序,用于不更新下拉列表部分,该部分有带筛选器的ng选项angular.forEach($(“选择”),函数(currSelect){currSelect.options[currSelect.selectedIndex].text+=“”;});
// This is an IE fix for not updating the section of dropdowns which has ng-options with filters
angular.forEach($("select"), function (currSelect) {
    console.log("1.text ", currSelect.options[currSelect.selectedIndex].text);
    console.log("1.label ", currSelect.options[currSelect.selectedIndex].label);
    //console.log("1.innerHTML ", currSelect.options[currSelect.selectedIndex].innerHTML);
    //console.log("1.textContent ", currSelect.options[currSelect.selectedIndex].textContent);
    //console.log("1.cN.data ", currSelect.options[currSelect.selectedIndex].childNodes[0].data);
    //console.log("1.cN.nodeValue ", currSelect.options[currSelect.selectedIndex].childNodes[0].nodeValue);
    //console.log("1.cN.textContent ", currSelect.options[currSelect.selectedIndex].childNodes[0].textContent);
    //console.log("1.cN.wholeText ", currSelect.options[currSelect.selectedIndex].childNodes[0].wholeText);
    //console.log("1. ", currSelect.options[currSelect.selectedIndex], "\n");

    //currSelect.options[currSelect.selectedIndex].label = "xyz";
    //currSelect.options[currSelect.selectedIndex].label = currSelect.options[currSelect.selectedIndex].text;
});