angularjs - dropdown population with ng-option -


i have html:

                <li class="dropdown">                     <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">current: {{currentapplication}}</a>                     <ul class="dropdown-menu" >                         <li ng-repeat="application in applications" ng-click="changeapplication(application.name)" >                             <a ui-sref="home">{{application.name}}</a>                         </li>                     </ul>                 </li> 

and want have application.id value, , application.name displayed value. how can it?

just pass application.id function on ng-change,

 <select ng-model="selected" ng-change="changeapplication(application.id)" ng-options="application.name application in applications"> 

demo

var app = angular.module('testapp',[]);  app.controller('myctrl',function($scope){      $scope.applications =[{    "id": 1,    "name": "alexandre"  }, {    "id": 2,    "name": "arvy"  }, {    "id": 3,    "name": "vidovic"  }]      });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    <div ng-app="testapp" ng-controller="myctrl">    <select ng-model="selected" ng-change="changeapplication(application.id)" ng-options="application.name application in applications">    </select>  </div>   


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -