I am pretty new to Angular JS. I have the below directive code and when I call 
this directive in html it works fine but if I enable compile function it does 
not. Anybody can guide me why it not working if I add compile function? And is 
it ok to have a button click functionality in link function or it should be 
written in directive controller?

    app.directive('datePickers',function(){
  
    return {
      restrict: 'AE', 
      template : '<button type="button" ng-click="clearField()">clear</button>',
      
      //compile: function(tElement,tAttributes){},
      
      link : function($scope,iElement,iAttribute){
       $scope.clearField= function() 
        {
           alert(" Clear");
        };    
      },      
      controller: function($scope, $element, $attrs){     
      }
  }
});

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to