title: pass $index as a parameter from directive template to directive's controller and use module controller's function in directive controller's function
body: <blockquote>
    <p>Here i am using <em>personManager</em> as a controller and <em>myPersonDirective</em> as directive. </p>
  </blockquote>
  
  <ul>
  <li><strike>How can i pass <strong><em>$index</em></strong> from template to deletePerson() function.</strike></li>
  <li>How can i use <strong><em>personManageInst.person</em></strong> in deletePerson(index) to perform splice() function on it.</li>
  </ul>
  
  <blockquote>
    <h2>myDirective.js</h2>
  
  <pre><code>var myDirModule = angular.module('myDirApp', []);
  var personManager = function()
  {
     var personManageInst = this;
     personManageInst.personsData = [
         {name: "Sam", age:33, city:"Delhi"},
         {name: "Mac", age:22, city:"Mumbai"},
     ];
     personManageInst.addNewMember = function()
     {
         personManageInst.personsData.push({name: personManageInst.name, age: personManageInst.age, city: personManageInst.city});      
     };
  };
  var myPersonDirective = function()
  {
    return{
      restrict: "AE",
      templateUrl: "personsTemplate.html",
      scope: {
          pers: "=",
          index: "@"
      },
      controller: function($scope){
          $scope.deletePerson = function(index)
          {
              console.log(index);     output: index no.
              personManageInst.personsData.splice(index, 1); //output: personManageInst is undefined
          };
      }
  }
  };
  myDirModule.controller("myPerCont", personManager).directive("personDir", myPersonDirective);
  </code></pre>
    
    <h2>personsTemplate.html</h2>
  
  <pre><code>&lt;tr&gt;
     &lt;td&gt;{{pers.name}}&lt;/td&gt;
     &lt;td&gt;{{pers.age}}&lt;/td&gt;
     &lt;td&gt;{{pers.city}}&lt;/td&gt;
     &lt;td&gt;
      &lt;button type="button" ng-click="deletePerson(index)"&gt;Delete&lt;/button&gt;
     &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
    
    <h2>myApp.html</h2>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;head&gt;add title, css, scripts&lt;/head&gt;
  &lt;/html&gt;
  &lt;body&gt;
     .
     .
     .
     &lt;tr person_dir pers="perso" index="{{$index}}" ng-repeat="perso in personManageInst.personsData"&gt;&lt;/tr&gt;
     .
     .
  &lt;/body&gt;
  </code></pre>
  </blockquote>