gpt4 book ai didi

angularjs - AngularJS 指令前链接和后链接功能可以自定义吗?

转载 作者:行者123 更新时间:2023-12-04 00:04:29 25 4
gpt4 key购买 nike

我看过很多对 AngularJS 的引用 链接前和链接后功能 在有关 AngularJS 的文献中。

但是,我不确定这些是否可以自定义或在框架内部。

换句话说,作为一个 AngularJS 开发者,我可以提供我自己的 前后链接功能到我的自定义指令?

最佳答案

是的,你可以,根据@Mikke 的回答。总结起来,链接函数的声明方式有四种:

  • 从内部 compile指定两者 preLinkpostLink明确的功能:
    compile: function compile(tElement, tAttrs, transclude) {
    return {
    pre: function preLink(scope, iElement, iAttrs, controller) { ... },
    post: function postLink(scope, iElement, iAttrs, controller) { ... }
    }
    }
  • 从内部 compile仅返回 postLink隐含地:
    compile: function compile(tElement, tAttrs, transclude) {
    return function postLink( ... ) { ... }
    }
  • 从内部 link指定两者 preLinkpostLink明确地:
    link: {
    pre: function preLink(scope, iElement, iAttrs, controller) { ... },
    post: function postLink(scope, iElement, iAttrs, controller) { ... }
    }
  • 来自于 link使用 postLink隐含地:
    link: function postLink( ... ) { ... }
  • 关于angularjs - AngularJS 指令前链接和后链接功能可以自定义吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22105336/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com