在我使用 html5 和 angular(版本 1.2.13)的第一个 Web 应用程序中,我遇到了select元素的问题。
虽然它在 Chrome 和 Firefox 中运行良好,但在 IE 8 中,第二个选择元素中的所有值都是重复的。
这是html部分:
<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="selsample">
<head>
<meta charset="UTF-8">
<title>NG Select Test</title>
<link href="styles/main.css" type="text/css" rel="stylesheet">
</head>
<body ng-controller="mainCtrl">
<h1>Select Example</h1>
<p>
<form name="myForm">
Select month
<select ng-model="selectedMonat" ng-options="m.monat for m in monate"></select>
<p>
select again
<!-- here all values are duplicated... -->
<select ng-model="selectedMonat" ng-options="m.monat for m in monate"></select>
</form>
<script src="lib/angular/angular.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers/mainCtrl.js"></script>
</body>
</html>
应用程序.js:
"user strict";
angular.module('selsample',[]);
这是控制器:
"use strict";
angular.module('selsample').controller('mainCtrl', function($scope) {
$scope.monate = [ {
"miy" : "01",
"monat" : "Jänner"
}, {
"miy" : "02",
"monat" : "Februar"
}, {
"miy" : "03",
"monat" : "März"
}, {
"miy" : "04",
"monat" : "April"
}, {
"miy" : "05",
"monat" : "Mai"
}, {
"miy" : "06",
"monat" : "Juni"
}, {
"miy" : "07",
"monat" : "Juli"
}, {
"miy" : "08",
"monat" : "August"
}, {
"miy" : "09",
"monat" : "September"
}, {
"miy" : "10",
"monat" : "Oktober"
}, {
"miy" : "11",
"monat" : "November"
}, {
"miy" : "12",
"monat" : "Dezember"
} ];
$scope.selectedMonat = $scope.monate[0];
});
任何想法这里可能有什么问题或如何解决这个问题?