tri_inn

tri_inn

  • NA
  • 1.2k
  • 235.2k

AngularJS: What compile function does

May 24 2017 5:58 AM
i am new in angular js.

just like to know about few line like what they does.
  1. app.directive('fancybox', function($compile) {  
  2. return {  
  3. restrict: 'A',  
  4. replace: false,  
  5. link: function($scope, element, attrs) {  
  6.   
  7. $scope.open_fancybox = function() {  
  8.   
  9. var el = angular.element(element.html()),  
  10.   
  11. compiled = $compile(el);  
  12.   
  13. $.fancybox.open(el);  
  14.   
  15. compiled($scope);  
  16.   
  17. };  
  18. }  
  19. };  
  20. }); 

below these lines are not clear.var el = angular.element(element.html()),  
  1. compiled = $compile(el);  
  2. $.fancybox.open(el);  
  3. compiled($scope); 
1) what $compile does and what it return after compile ? 2) when we need to compile scope like compiled($scope);

i have test the if i comment this line compiled($scope); then value is not putting into expression.......why ?

please guide me in detail. thanks

Answers (2)