AngularJs+;TypeScript:如何在角度控制器中实现if-else条件

AngularJs+;TypeScript:如何在角度控制器中实现if-else条件,angularjs,typescript,angular-ng-if,Angularjs,Typescript,Angular Ng If,我正在尝试在angular controller中实现if-else条件。我获取了一个下拉列表,并在其索引更改时绑定了另一个下拉列表。我也尝试了ng if,但它会将整个下拉列表隐藏在我希望下拉列表可见的位置。以下是我的html代码:- <div data-ng-app="CustomerNew" data-ng-controller="CreateCustomerCtrl as custom" ng-init="getFormData();"> <table style="wi

我正在尝试在angular controller中实现if-else条件。我获取了一个下拉列表,并在其索引更改时绑定了另一个下拉列表。我也尝试了ng if,但它会将整个下拉列表隐藏在我希望下拉列表可见的位置。以下是我的html代码:-

<div data-ng-app="CustomerNew" data-ng-controller="CreateCustomerCtrl as custom" ng-init="getFormData();">
<table style="width: 144% ! important;" class="TableStyle1" id="Table1" cellspacing="0" cellpadding="2" border="0">
    <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>
如果选择的索引值是3,4,5,我想在这里输入,它将进入我的api,否则将返回空白。试试看

<table style="width: 144% ! important;" class="TableStyle1" id="Table1" cellspacing="0" cellpadding="2" border="0">
    <tr>
        <td>Billing Type:</td>
        <td ng-if="custom.listBillingType !== '1'"> // if condition
            <select id="listBillingType" >
               // your options
            </select>
        </td>
        <td ng-if="custom.listBillingType === '1'"> // else condition
            <select id="listBillingType" >
               // your options
            </select>
        </td>
        </tr>

计费类型:
//如果条件
//你的选择
//其他条件
//你的选择

我已经用下面的方式解决了这个问题,或者在我的打字脚本或角度控制器中添加了一些更改。但是我仍然对如何将dropdwon放在更改上感到困惑

 public listBillingTypeselectedindexchange = (index) => {
             debugger;
             var indexvalue = {
                 BillingTypesindex: index
             }
             if (index === "3" || index === "4" || index === "5") {
                 this.$http.put(dolistsalesindex, indexvalue).
                     success((data, status, headers, config) => {
                     debugger;
                     this.$scope.listParentAccount = data["listParentAccount"];
                 }).
                     error((data, status) => {
                     debugger;
                     console.log("In Error:-in index");
                     alert(data);
                 });
             }

你放在哪个地方?
<table style="width: 144% ! important;" class="TableStyle1" id="Table1" cellspacing="0" cellpadding="2" border="0">
    <tr>
        <td>Billing Type:</td>
        <td ng-if="custom.listBillingType !== '1'"> // if condition
            <select id="listBillingType" >
               // your options
            </select>
        </td>
        <td ng-if="custom.listBillingType === '1'"> // else condition
            <select id="listBillingType" >
               // your options
            </select>
        </td>
        </tr>
 public listBillingTypeselectedindexchange = (index) => {
             debugger;
             var indexvalue = {
                 BillingTypesindex: index
             }
             if (index === "3" || index === "4" || index === "5") {
                 this.$http.put(dolistsalesindex, indexvalue).
                     success((data, status, headers, config) => {
                     debugger;
                     this.$scope.listParentAccount = data["listParentAccount"];
                 }).
                     error((data, status) => {
                     debugger;
                     console.log("In Error:-in index");
                     alert(data);
                 });
             }