title: get parent index of array in angularjs
body: <p>I have array of scope.students inside the controller. And the data is shown in my view form using ng-repeat in the table. What I want to do now is when I click the button, it should alert the parent index of the specific object. For example I click the button for 1 Brick Med then it should alert 0 because he is in section A. Then when I click the button in 3 it should alert 1 because he is sectionB. I am really new in angularjs any help is millions appreciated thanks</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var stud = angular.module("stud", []);
  stud.controller("StudentsController", function ($scope) {
   'use strict';
    
    
      $scope.alertMe = function (key){
       alert(0);
      };  
  
      $scope.sectionA = [
        {
          no:1,
          name:'Brick Med',
        },
        {
          no:2,
          name: 'Colin Christopher',
        },
      ];
        
       $scope.sectionB = [
        {
          no:3,
          name: 'Frank Joemar Timbang',
        },
        {
          no:4,
          name: 'Curtis Zaymond',
        }
        ];
      
      $scope.students = [
        $scope.sectionA,
        $scope.sectionB
      ];
  
       
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html data-ng-app="stud"&gt;
  &lt;head lang="en"&gt;
   &lt;meta charset="utf-8"&gt;
   &lt;title&gt;Tally Boxes&lt;/title&gt;
  &lt;/head&gt;
  &lt;body data-ng-controller="StudentsController" data-ng-init="init()"&gt;
    &lt;div id="container"&gt;
     &lt;/div&gt;
    &lt;div class="container-table"&gt;
      &lt;table border="1" width="100%"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;td&gt;Students&lt;/td&gt;
                  &lt;td&gt;Alert&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr ng-repeat="(key,value) in students[0]"&gt;
                  &lt;td&gt;{{value.no}} {{value.name}}&lt;/td&gt;
                &lt;td&gt;&lt;button ng-click="alertMe(key)"&gt;Alert me!&lt;/button&gt;&lt;/td&gt;
                   
              &lt;/tr&gt;
             &lt;tr ng-repeat="(key,value) in students[1]"&gt;
                  &lt;td&gt;{{value.no}} {{value.name}}&lt;/td&gt;
                &lt;td&gt;&lt;button ng-click="alertMe(key)"&gt;Alert me!&lt;/button&gt;&lt;/td&gt;
                   
              &lt;/tr&gt;
          &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  
    &lt;script src="angular.min.js"&gt;&lt;/script&gt;  
    &lt;script src="tallyboxController.js"&gt;&lt;/script&gt;
    &lt;script src="tallyboxDirective.js"&gt;&lt;/script&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>