{
"numDetails" : [
{
"code" : "ABC",
"num" : "246810","4681012","681012"},
{
"code" : "DEF",
"num" : "13579","357913","5791315"}
]
}
当代码被ABC选中时,num值应该在options中逐个显示。请告诉我如何在html中编写ng-options。
答案 0 :(得分:1)
如果我找到了你,那么你正在寻找类似这样的东西
<doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body ng-app="myApp" data-ng-controller="HomeCtrl">
<select ng-model="opt" ng-options="obj.num as obj.code for obj in opts">
<option value="">select</option>
</select>
<select ng-model="opt1" ng-options= "obj1 for obj1 in opt">
<option value="">select</option>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script>
angular.module('myApp', []);
angular.module('myApp').controller('HomeCtrl', ['$scope', function($scope) {
$scope.opts = [
{
"code" : "ABC",
"num" : ["246810","4681012","681012"]
},
{
"code" : "DEF",
"num" : ["13579","357913","5791315"]
}
]
}]);
</script>
</body>
</html>