Javascript AngularJS选择框,在IE中有2000个选项
我知道选择框中的2000个选项会带来一些性能问题,但它在Chrome、Firefox和Safari上运行良好 基本上,我调用的是一个填充选择框的web服务。这相当快,并且在初始加载时性能良好。问题是当我改变路线,然后返回带有选择框的页面时。在IE上加载视图大约需要40秒。是否有任何方法可以提高性能 这是如何设置的:Javascript AngularJS选择框,在IE中有2000个选项,javascript,angularjs,Javascript,Angularjs,我知道选择框中的2000个选项会带来一些性能问题,但它在Chrome、Firefox和Safari上运行良好 基本上,我调用的是一个填充选择框的web服务。这相当快,并且在初始加载时性能良好。问题是当我改变路线,然后返回带有选择框的页面时。在IE上加载视图大约需要40秒。是否有任何方法可以提高性能 这是如何设置的: <select name="" id="" ng-model="model.searchParams.shipto" ng-options="ship.cd as sh
<select name="" id="" ng-model="model.searchParams.shipto" ng-options="ship.cd as ship.cd + (ship.cd===''?'' : ' - ') + ship.ds for ship in shiptoSelect" class="dropdownbar"></select>
这是用于检索结果的调用。这只执行一次,然后结果存储在我的globalParams中。因此,当我返回此视图时,不会执行此操作,结果将从我的globalParams服务加载。这就是我遇到性能问题的时候
$scope.getShipTo = function() {
$scope.model.searchParams.shipto = '';
$scope.model.showProgress = true;
MagicAPI.getShipToResults($scope.model.searchParams.brand, $scope.model.searchParams.soldto).then(function(response) {
if (response.status === 200) {
var resSHIPAR = eval(response.data);
var resSHIPStr = resSHIPAR;
if (resSHIPStr.length * 1 === 0) {
globalParams.getAlertList().push({
type: 'info',
msg: 'No ship-to\'s exist for this account.'
});
$scope.model.showProgress = false;
return;
} else {
var selectObj = {
cd: '',
ds: '-- select --'
};
resSHIPStr.splice(0, 0, selectObj);
globalParams.setShipToList(resSHIPStr);
$scope.shiptoSelect = resSHIPStr;
$scope.model.showProgress = false;
for (var i = 0; i < resSHIPStr.length; i++) {
if(resSHIPStr[i].cd === $scope.model.searchParams.soldto) {
$scope.isSoldToMatch = true;
return;
} else {
$scope.isSoldToMatch = false;
}
}
if ($scope.isSoldToMatch === false) {
globalParams.getAlertList().push({
type: 'info',
msg: 'No ship-to\'s exist for this account.'
});
}
}
}
}, function(response) {
$log.debug(response);
});
};
您应该真正了解跟踪并实施它 然后你的选择变成
<select name="" id=""
ng-model="model.searchParams.shipto"
ng-options="ship.cd as ship.cd + (ship.cd===''?'' : ' - ') + ship.ds for ship in shiptoSelect track by ship.id" class="dropdownbar"></select>
尽量不要使用ngOptions呈现selectbox,使用不会创建绑定的自定义指令。