AngularJs+TypeScript:-How to get the selected index value in ng-select -


i m working on module have check condition visibility of panel if slected index of dropdown not equal 0 or -1 make visible panel else not. bit confused how selected index value of dropdown using ng-select. have shown dropdown code below:-

 <div data-ng-app="customernew" data-ng-controller="createcustomerctrl custom"  ng-init= getformdata(); > <table> <tr>      <td>                                                   <select id="accountselector" style="width: 100%;">      <option value="0">--- select option ---</option>     <option data-ng-repeat="acnt in listaccounttypes" value="{{acnt.id}}">{{acnt}}</option>     </select>     </td></tr> </table> </div> 

here typescript controller

/// <reference path="../interface/interface.ts" /> /// <reference path="../../scripts/typings/jquery/jquery.d.ts" /> /// <reference path="../../scripts/typings/angularjs/angular.d.ts" />  module customernew.controllers {     export class createcustomerctrl {         static $inject = ['$scope', '$http', '$templatecache'];         constructor(protected $scope: icustomerscope,             protected $http: ng.ihttpservice,             protected $templatecache: ng.itemplatecacheservice) {             $scope.getformdata = this.getformdata;         }            public getformdata = (getformdata: any) => {             this.$http.get(doaccounttypeurl).                 success((data, status, headers, config) => {                 this.$scope.listaccounttypes = data["accountcodesdisplaytypes"];             }).                 error((data, status) => {                 debugger;                 console.log("in error:-request failed");                 alert(status);             });         }       }     var customerapp = angular.module("customernew", []);     customerapp       .controller('createcustomerctrl', customernew.controllers.createcustomerctrl);     var doaccounttypeurl = '/api/create/getloaddata'; } </controller> 

condition have check:

if (listaccounttypes.selectedindex > -1 && listaccounttypes.selectedvalue != "0")  {  intlcountryaddres objintlcountryaddres = objintlcountryaddresscontroller.getbycountryid(convert.toint32(listaccounttypes.selectedvalue));  if (objintlcountryaddres != null && objintlcountryaddres.id > 0)     {        pnlbillingcountry.visible = true;        loadbillinginfo(objintlcountryaddres);     }      }  else     {       pnlbillingcountry.visible = false;     } 

note:-i checking condition on page load getting data in below format:- enter image description here

don't have option inline:

<select id="accountselector" style="width: 100%;">  <option value="0">--- select option ---</option> 

instead use ng-options , ng-model:

<select id="accountselector" style="width: 100%;" ng-options="check docs" ng-model="check docs"></select> 

check docs : https://docs.angularjs.org/api/ng/directive/ngoptions


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -