0

Я реализовал модуль с использованием TypeScript и Angular Js. Я заполнил раскрывающийся список, используя ng-options, где im использует ng-change too. Теперь я хочу отправить индекс выбранного значения и это выбранное значение в функцию, называемую ng-change, и установить это значение для функции too.so, что i могут отправлять эти значения в мой API-контроллер. Вот мой код DropDown: -TypeScript + AngularJs: - Как передать параметры через ng-Change to typescript function

<div data-ng-app="CustomerNew" data-ng-controller="CreateCustomerCtrl as custom" ng-init="getFormData();"> 
    <tr> 
    <td>Billing Type:</td> 
    <td> 
    <select id="listBillingType" 
    ng-change="listBillingTypeselectedindexchange((index.Of(blngtypee),(custom.listBillingType))"data-ng-options="blngtype as blngtypee for (blngtype,blngtypee) in listBillingType" 
    data-ng-model="custom.listBillingType" 
    style="width: 182px !important; height: 34px;"> 
    <option value="">Choose an option {{optional ? '(optional)' : ''}}</option> 
    </select> 
    </td></tr> 
</div> 

Вот моя машинопись коды контроллера: -

public listBillingTypeselectedindexchange = (listBillingTypeselectedindexchange: any) => { 
      debugger; 
      var data = { 
      index:here is want to set the value of my index 
      selectedvalue:here i want to set the value of my selected value 
      } 
      this.$http.post(doAccountTypeUrl,data). 
       success((data, status, headers, config) => { 
       debugger; 
      }). 
       error((data, status) => { 
       debugger; 
       console.log("In Error:-in index"); 
       alert(status); 
      }); 

     } 

Как вы можете видеть, если я получил оба значения так им возможность отправлять то же самое на мой контроллер ,

ответ

0

я получил ответ, мы можем передать параметры вроде как я показано ниже: -

<div data-ng-app="CustomerNew" data-ng-controller="CreateCustomerCtrl as custom" ng-init="getFormData();"> 
<tr> 
<tr> 
<td>Billing Type:</td> 
<td> 
<select id="listBillingType" ng- change="listBillingTypeselectedindexchange(custom.listBillingType)" 
data-ng-options="blngtype as blngtypee for (blngtype,blngtypee) in listBillingType" 
data-ng-model="custom.listBillingType" style="width: 182px !important; height: 34px;"> 
<option value="">Choose an option {{optional ? '(optional)' : ''}}</option> 
</select> 
</td> 
</tr> 
</div> 

In My машинопись Controller: -

public listBillingTypeselectedindexchange = (Item) => { 
     debugger; 
     var data = { 
      selecteditem: Item 
     } 
     this.$http.post(Url,data). 
      success((data, status, headers, config) => { 
     }). 
      error((data, status) => { 
      console.log("In Error"); 
      alert(status); 
     });