Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9218651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:54:48+00:00 2026-06-18T02:54:48+00:00

From the doc of angularjs, when defining a directive, there’s a postLink in compile

  • 0

From the doc of angularjs, when defining a directive, there’s a postLink in compile, and a postLink in link

myModule.directive('directiveName', function factory(injectables) {
  var directiveDefinitionObject = {
    priority: 0,
    template: '<div></div>',
    templateUrl: 'directive.html',
    replace: false,
    transclude: false,
    restrict: 'A',
    scope: false,
    compile: function compile(tElement, tAttrs, transclude) {
      return {
        pre: function preLink(scope, iElement, iAttrs, controller) { ... },
        post: function postLink(scope, iElement, iAttrs, controller) { ... }
      }
    },
    link: function postLink(scope, iElement, iAttrs) { ... }
  };
  return directiveDefinitionObject;
});

What’s the difference between them? I notice the postLink in link has a argument less than the one in compile. And are there any other difference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:54:49+00:00Added an answer on June 18, 2026 at 2:54 am

    They’re no different, what you have there is just psuedo-code from the documentation. The postLink function is just the most important one, so there are a variety of ways to declare it.

    Here is a Plunker as an example…

    … and here is some psuedo code showing the different declarations of a postLink function:

    app.directive('dir1', function () {
       return function(scope, elem, attr) {
           //this is the same
       };
    });
    
    app.directive('dir2', function () {
       return {
           link: function(scope, elem, attr) {
               //this is the same
           }
       };
    });
    
    app.directive('dir3', function () {
       return {
          compile: function compile(tElement, tAttrs, transclude) {
             return {
               post: function postLink(scope, elem, attrs) {
                  //this is the same
               }
             }
          }
       };
    });
    

    … you only need one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having this link statement: List<UserGroup> domains = UserRepository.Instance.UserIsAdminOf(currentUser.User_ID); query = (from doc in
From the play2's doc: http://www.playframework.org/documentation/2.0/ScalaForms , there is a sample code: val loginForm =
Is there any way to extract hyperlinks from .doc. I got bunch of hyperlinks
From MSDN doc : A delegate is a type that safely encapsulates a method,
From apple doc subview(near to the screen) gets to handle a touch event first
i don't understand this example from the doc : the timeIntervalSinceNow method should show
I'm trying to get the hello world app running from the doc . I
var cityList = from country in doc.Element(result) .Element(cities) .Descendants(city) select new { Name =
I have learned from the sencha doc how to create a simple MVC application,
Please consider the following example code (from the lm doc): ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.