title: How to get the name of model passed into the function in AngularJS?
body: <p>I have a scenario where i need to know the value and name of model passed in to the function. </p>
  
  <p>I tried the following</p>
  
  <pre><code>$scope.rad='fff';
  
  app.directive('kmRadio', function() {
    return{
      restrict:'E',
      compile: function(element,attrs) 
      {
        var model = {l:''};
        model.l = attrs.kmModel;
        var str1="n in ";
        var str2=attrs.kmOption;
        var repeat=str1.concat(str2);
        var htmlText='&lt;div&gt;&lt;div ng-switch on="format"&gt;'+
              '&lt;div ng-switch-when="kmForm"&gt;'+
              '&lt;div&gt;'+
              '&lt;div class="floatLeft"&gt;'+
              ''+attrs.title+''+
              '&lt;/div&gt;'+
              '&lt;ul&gt;'+
              '&lt;li class="rowlist" ng-repeat="'+repeat+'"&gt;&amp;nbsp;{{n}}&lt;input type="radio" ng-model="'+attrs.kmModel+'" name="a"  ng-click="radioValueChanged(n,'+attrs.kmModel+')"/&gt;&lt;/option&gt;'+
              '&lt;/ul&gt;'+
              '{{'+attrs.kmModel+'}}'+
              ''+attrs.kmModel+''+
              ''+model.l+''+
              '&lt;/div&gt;'+
              '&lt;/div&gt;'+
              '&lt;div ng-switch-when="kmPreview"&gt;'+
              '&lt;div&gt;'+attrs.title+'&lt;input type="radio" ng-model="'+attrs.kmModel+'" disabled="true"/&gt;&lt;/div&gt;'+
              '&lt;/div&gt;'+
              '&lt;/div&gt;&lt;/div&gt;';
              element.replaceWith(htmlText);
      }
    }
  })
  </code></pre>
  
  <p>The following code is responsible for calling the function</p>
  
  <pre><code>'&lt;li class="rowlist" ng-repeat="'+repeat+'"&gt;&amp;nbsp;{{n}}&lt;input type="radio" ng-model="'+attrs.kmModel+'" name="a"  ng-click="radioValueChanged(n,'+attrs.kmModel+')"/&gt;&lt;/option&gt;'+
  
  
  
  $scope.radioValueChanged = function (value,model) {
      //alert("Changed value"+value + model);
      alert(value +" and " + model);
      //alert("model "+ model );
  }
  </code></pre>
  
  <p>In HTML , i have a code like below</p>
  
  <pre><code>    &lt;km-radio km-model="rad" title="Gender" km-option="['De','CM','PM']"&gt;&lt;/km-radio&gt;
  </code></pre>
  
  <p>When i tap on radio button in html, i am getting the <strong>o/p De and fff</strong>, but what i need is <strong>o/p De and rad</strong></p>
  
  <p>See <a href="http://plnkr.co/edit/gJlROG?p=preview" rel="nofollow">the plunker code</a> and check the directive <strong>kmRadio</strong></p>