How can we achieve transclusion using link function and directive controller?

0 votes
I want the generic code or any sample code in order to achieve transclusion using link or directive function.
Feb 5 in Angular by anonymous
• 1,910 points
23 views

1 answer to this question.

0 votes

Hey,

The Term Transclusion means unhidding the context that is already present in the element level along with the template content.

Let us first consider achieving transclusion using link function:

   The generic code is:

     app.directive(' Message', function(){

         return{

                  templateUrl: info.html,

                  transclude:true,

                  link: function(scope, iElement, iAttrs, controller, transclude){

                                  var content=transclude();

                                  iElement.find(#innerpannel).append(content)

                          }

                     }  }

Now, consider the second case that is to achieve transclusion using diricitive controller:

The generic code is:

   app.directive(' Message', function(){

         return{

                  templateUrl: info.html,

                  transclude:true,

                  Controller: function($scope, $element, $Attrs, $transclude){

                                  var content=$transclude();

                                  $element.find(#innerpannel).append(content)

                          }

                     }  }

Hope this will help you to generate transclusion!!

answered Feb 5 by Niroj
• 3,230 points

Related Questions In Angular

0 votes
1 answer

How can we reload a page after requesting the same get parameter using AngularJS?

hey kartik, The reason for this is that ...READ MORE

answered Feb 10 in Angular by Niroj
• 3,230 points
18 views
0 votes
1 answer

How compile, controller, pre-linking and post linking works in Angularjs?

Explanation of compile and link process don't ...READ MORE

answered Jan 31 in Angular by Niroj
• 3,230 points
18 views
0 votes
1 answer

What is the difference between Call back transclusion function and no call back transclusion function?

Hey,    There is no difference between clone linking and ...READ MORE

answered Feb 5 in Angular by Niroj
• 3,230 points
25 views
0 votes
1 answer
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 29 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 30 views
0 votes
1 answer

Explain the difference between visibility:hidden; and display:none?

hii, visibility:hidden; and display:none are totally different used ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points
57 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 31 views
0 votes
1 answer

How can we achieve transclusion in AngularJs?

Hii,  In order to know what transclusion is ...READ MORE

answered Feb 5 in Angular by Niroj
• 3,230 points
15 views
0 votes
1 answer

How can we redirect to an existing route using ngRoute?

Routing is just another way of fixing some content ...READ MORE

answered Feb 6 in Angular by Niroj
• 3,230 points
19 views