我想实现一个if else条件角控制器。我采取了下拉和其索引更改我绑定我的另一个下降。我试过NG-如果太多,但它会隐藏整个下拉,我想下拉可见。这里是我的html代码: -AngularJs + TypeScript:如何实现如果条件在角控制器
<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>
我正努力以填充上述下拉指数的基础上,另一种下拉。
<tr>
<td nowrap style="height: 26px">Parent Account:</td>
<td style="height: 26px">
<select id="listParentAccount" data-ng-options="prntact as prntact.AccountNumber +' - '+ prntact.FullName for prntact in listParentAccount" ng-model="custom.listParentAccount" style="width: 182px !important; height: 34px;">
<option value="">Choose an option {{optional ? '(optional)' : ''}}</option>
</select>
</td>
</tr>
这里是我的控制器
module CustomerNew.controllers {
export class CreateCustomerCtrl {
static $inject = ['$scope', '$http', '$templateCache'];
debugger;
constructor(protected $scope: ICustomerScope,
protected $http: ng.IHttpService,
protected $templateCache: ng.ITemplateCacheService) {
$scope.listBillingTypeselectedindexchange = this.listBillingTypeselectedindexchange;
}
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);
});
}
}
在这里,我想,如果选择的索引值3,4,5不仅仅是它会去我的API否则将返回空白。
哪个地方你把ng-if? –