gpt4 book ai didi

javascript - 简单的 ng-Repeat 用于选择框的选项

转载 作者:行者123 更新时间:2023-11-28 18:57:18 25 4
gpt4 key购买 nike

我正在使用ng-repeat简单地从数组中放下选项。不过,我希望我做得很好,我在选择选项的下拉列表中看不到任何选项。有人可以帮我找出错误吗?

var myApp = angular.module("myApp", []);

myApp.controller('myCtrl', function($scope) {

$scope.Country = [
"India","Pakistan","Germany"

];
});
<html>
<head>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<select>
<option ng-repeat="x in Country"></option>
</select>
</body>
</html>

最佳答案

试试这个:::

<html>
<head>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<select ng-model ="selectedCountry">
<option ng-repeat="x in Country" value = "{{x}}"> {{x}} </option>
</select>

<script>
var myApp = angular.module("myApp", []);

myApp.controller('myCtrl', function($scope) {

$scope.Country = [
"India","Pakistan","Germany"

];
});
</script>
</body>
</html>

关于javascript - 简单的 ng-Repeat 用于选择框的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33362241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com