How does implicit/inline/$inject dependency injection work in AngularJS?

后端 未结 2 911
暖寄归人
暖寄归人 2020-12-30 14:23

I\'m new to AngularJS and I would like to understand more about the dependencies that are being injected by default. While reading through code I\'ve noticed that sometimes

2条回答
  •  有刺的猬
    2020-12-30 14:28

    Just to provide a different sort of answer, as to the how inline/implicit dependencies work in AngularJS. Angular does a toString on the provided function and parses the parameter names from the string which is produced. Example:

    function foo(bar) {}
    foo.toString() === "function foo(bar) {}"
    

    References:

    source code

    AngularJS Dependency Injection - Demystified

提交回复
热议问题