Can AngularJS directive pre-link and post-link functions be customized?

前端 未结 2 906
盖世英雄少女心
盖世英雄少女心 2021-02-03 10:16

I have seen many references to AngularJS pre- and post-link functions in literature about AngularJS.

I am not sure however whether these can be customiz

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-03 10:52

    Yes, you can provide your own pre and post link functions. See the directive blueprint at Angular Docs' Comprehensive Directive API.

    {
        compile: function compile(tElement, tAttrs, transclude) {
            return {
                pre: function preLink(scope, iElement, iAttrs, controller) { ... },
                post: function postLink(scope, iElement, iAttrs, controller) { ... }
            }
            // or
            // return function postLink( ... ) { ... }
        },
    }
    

提交回复
热议问题