AngularJs+TypeScript: How to implement if else condition in Angular Controller -


i trying implement if else condition in angular controller.i have taken dropdown , on index change binding drop down.i have tried ng-if hide whole dropdown want dropdown visible .here html code:-

<div data-ng-app="customernew" data-ng-controller="createcustomerctrl 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 blngtypee (blngtype,blngtypee) in listbillingtype" data-ng-model="custom.listbillingtype" style="width: 182px !important; height: 34px;">                 <option value="">choose option {{optional ? '(optional)' : ''}}</option>             </select>         </td>     </tr> 

another dropdown trying populate on basis of above dropdown index.

<tr>     <td nowrap style="height: 26px">parent account:</td>     <td style="height: 26px">         <select id="listparentaccount" data-ng-options="prntact prntact.accountnumber +' - '+ prntact.fullname prntact in listparentaccount" ng-model="custom.listparentaccount" style="width: 182px !important; height: 34px;">             <option value="">choose option {{optional ? '(optional)' : ''}}</option>         </select>     </td> </tr> 

here controller

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);             });         }     } 

here want if selected index value 3,4,5 go api else return blank.

try

<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" >                // options             </select>         </td>         <td ng-if="custom.listbillingtype === '1'"> // else condition             <select id="listbillingtype" >                // options             </select>         </td>         </tr> 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -