title: AngularJs+TypeScript:-How to get the selected index value in ng-select
body: <p>I m working on module where I have check a condition for the visibility of a panel as if slected index of a dropdown is not equal to 0 or -1 than it will make visible to my panel else it will not. I am bit confused as how to get the selected index value of my dropdown using <strong><code>ng-select</code></strong>. I have shown my dropdown code below:- </p>
  
  <pre><code> &lt;div data-ng-app="CustomerNew" data-ng-controller="CreateCustomerCtrl as custom"  ng-init= getFormData(); &gt;
  &lt;table&gt;
  &lt;tr&gt;
       &lt;td&gt;                                             
       &lt;select id="accountselector" style="width: 100%;"&gt;
       &lt;option value="0"&gt;--- Select an option ---&lt;/option&gt;
      &lt;option data-ng-repeat="acnt in listAccountTypes" value="{{acnt.id}}"&gt;{{acnt}}&lt;/option&gt;
      &lt;/select&gt;
      &lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my typescript controller
  </p>
  
  <pre><code>/// &lt;reference path="../interface/interface.ts" /&gt;
  /// &lt;reference path="../../scripts/typings/jquery/jquery.d.ts" /&gt;
  /// &lt;reference path="../../scripts/typings/angularjs/angular.d.ts" /&gt;
  
  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) =&gt; {
              this.$http.get(doAccountTypeUrl).
                  success((data, status, headers, config) =&gt; {
                  this.$scope.listAccountTypes = data["AccountCodesDisplayTypes"];
              }).
                  error((data, status) =&gt; {
                  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';
  }
  &lt;/Controller&gt;
  </code></pre>
  
  <p>Condition Which i have to check:</p>
  
  <p></p>
  
  <pre><code>if (listAccountTypes.SelectedIndex &gt; -1 &amp;&amp; listAccountTypes.SelectedValue != "0")
   {
   IntlCountryAddres objIntlCountryAddres = objIntlCountryAddressController.GetByCountryId(Convert.ToInt32(listAccountTypes.SelectedValue));
   if (objIntlCountryAddres != null &amp;&amp; objIntlCountryAddres.id &gt; 0)
      {
         pnlBillingCountry.Visible = true;
         LoadBillingInfo(objIntlCountryAddres);
      }
       }
   else
      {
        pnlBillingCountry.Visible = false;
      }
  </code></pre>
  
  <p></p>
  
  <p>Note:-I am checking this condition on page load
  I am getting data in below format:-
  <img src="https://i.stack.imgur.com/nIU3g.jpg" alt="enter image description here"></p>