pass dropdown selected item to controller angularjs javascript restful -


i tried adapt similar cases using asp.net, ajax, regular dropdownlist, didn't work in case. need pass selected value controller, , after send through rest database. string values "description": "normal" , "version": "new" stored, others should come dropdownlist in blank on database. me resolve please?

#####################controller side .controller('ctrl', function ($scope, response, $location) {  $scope.ddselectedname1 = {}; $scope.ddselectedgift = {}; $scope.ddselectedname2 = {};       var response = {"name": $scope.ddselectedname1,                       "gift": $cope.ddselectedgift,                      "name": $scope.ddselectedname2,                       "description": "normal", "version": "new"};     $scope.saveresponse = function() {      response.post(response).then(function() {         $location.path('/responses');      });     };      $scope.ddselectgift = [       {         gift: 'a',       },         gift: 'b'       }           ];     $scope.ddselectname1 = [       {         name1: 'pp',       },       {         name1: 'xx'       }           ];     $scope.ddselectgift = [       {         name2: 'gg',       },       {         name2: 'ss'       }           ];  ######################template side     <td>         <div ng-controller="ctrl">         <p>you have selected: {{ ddselectedname1.name1 }}</p>           <div dropdown-select="ddselectname1"                dropdown-model="ddselectedname1"                dropdown-item-label="name1">           </div>         </div>     </td>     <td>         <div ng-controller="ctrl">           <p>you have selected: {{ ddselectedname2.name2 }}</p>           <div dropdown-select="ddselectname2"                dropdown-model="ddselectedname2"                dropdown-item-label="name2">           </div>         </div>     </td>     <td>       <div ng-controller="ctrl">         <p>you have selected: {{ ddselectedgift.gift }}</p>         <div dropdown-select="ddselectgift"              dropdown-model="ddselectedgift"              dropdown-item-label="gift">         </div>       </div>     </td> 

the best way use ng-model in dom element automatically pass selected value controller using two-way data binding.

also, way using controller in html granular. please try using in common div instead of each , every div, if situation not calls it.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -