1
  {

    "numDetails" : [

                         {

                           "code" : "ABC",

                           "num" : "246810","4681012","681012"},

                         {   
                           "code" : "DEF",

                           "num" : "13579","357913","5791315"}

                       ]

   }

when code is ABC selected the num values should be displayed one by one in options.Please let me know how to write ng-options in html.

1 Answer 1

1

if I got you correctly then you are looking for something like this

<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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.