[英]Difference with use of using Select as in ng-options
Select box in IE is causing a problem in the opening for the first time when used with identity as identity.identityName for identity in identityProofList track by identity.identityId
or ng-repeat
but when used without identity as
, it is working fine and can not see any difference in the functionality of select box also. IE中的选择框在首次使用
identity as identity.identityName for identity in identityProofList track by identity.identityId
或ng-repeat
identity as identity.identityName for identity in identityProofList track by identity.identityId
时出现问题,但是在不使用identity as
,它工作正常并且不能还可以看到选择框功能上的任何差异。
<select name="identityProof" ng-model="identityProof" ng-change="changeProofOfIdentity(identityProof)" ng-options="identity.identityName for identity in identityProofList track by identity.identityId" id="identityProofList" >
Where identityProofList is array of objects having properties identityName and identityId. 其中identityProofList是具有属性identityName和identityId的对象的数组。
What is difference b/w the both? 两者的黑白有何不同?
Why ng-repeat
is causing problem with IE11. 为什么
ng-repeat
导致IE11问题。
What is difference b/w the both?
两者的黑白有何不同?
Do you mean the difference between ng-repeat and ng-options ? 您是说ng-repeat和ng-options之间的区别吗?
The difference between using them to create DropdownList is that: 使用它们创建DropdownList的区别在于:
Dropdowns made with ng-options allows the selected value to be an object, while dropdowns made from ng-repeat has to be a string. 使用ng-options进行的下拉列表允许所选值成为对象,而通过ng-repeat进行的下拉列表则必须是字符串。
More details, check the AngularJS Select Boxes . 更多详细信息,请检查AngularJS选择框 。
Why ng-repeat is causing problem with IE11 is also with using .
为什么ng-repeat导致IE11出现问题也是使用。
According to your codes, I create a sample using the following code, it works well on my IE browser (11.17134.1.0), you could refer to it. 根据您的代码,我使用以下代码创建示例,该示例在我的IE浏览器(11.17134.1.0)上运行良好,您可以参考它。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<p>Select a identity:</p>
<select ng-model="selectedidentity">
<option ng-repeat="x in identityProofList " value="{{x.identityId}}">{{x.identityName}}</option>
</select>
<h1>You selected: {{selectedidentity}}</h1><br />
<select name="identityProof" ng-model="identityProof" ng-change="changeProofOfIdentity(identityProof)"
ng-options="identity as identity.identityName for identity in identityProofList track by identity.identityId"
id="identityProofList"></select>
<h1>You selected: {{selectedvalue}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
$scope.identityProofList = [
{ identityId: "1001", identityName: "Admin" },
{ identityId: "1002", identityName: "User" },
{ identityId: "1003", identityName: "Customer" }
];
$scope.selectedvalue = "";
$scope.changeProofOfIdentity = function (identity) {
$scope.selectedvalue = identity.identityName;
}
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.