angularjs - Displaying Array Values in Select Dropdown using ng-options -
{ "numdetails" : [ { "code" : "abc", "num" : "246810","4681012","681012"}, { "code" : "def", "num" : "13579","357913","5791315"} ] }
when code abc selected num values should displayed 1 one in options.please let me know how write ng-options in html.
if got correctly looking 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 obj.code obj in opts"> <option value="">select</option> </select> <select ng-model="opt1" ng-options= "obj1 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>
Comments
Post a Comment