0
我已經使用TypeScript和Angular Js實現了一個模塊。我已經使用ng-options填充了一個下拉列表,其中im也使用了ng-change.Now我想將選定值的索引和選定的值發送到ng-change上調用的函數,並將該值設置爲功能。因此,我可以將這些值發送到我的API控制器。 這裏是我的下拉代碼: -TypeScript + AngularJs: - 如何通過ng參數傳遞 - 更改爲打印腳本功能
<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);
});
}
正如你可以看到,如果我有兩個值,以便即時通訊能夠在同一發送到我的控制器。