R
R
Roman2017-02-02 08:42:27
JavaScript
Roman, 2017-02-02 08:42:27

Anqular: how does the framework parse dependencies?

How does Angular detect dependencies based on a function signature of the form function($service1, $service2,...)?
Does the kernel parse the function's source code and extract the argument names from it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
Timurkin, 2017-02-02
@DarkGenius

anandmanisankar.com/posts/angularjs-dependency-inj...

X
xmoonlight, 2017-02-02
@xmoonlight

Recursive overloading (or searching for a "leaf in a tree") is quite possible.
Perhaps it also initially checks that all input variables do not contain undefined.
Exact option: look at the source and understand the logic)

L
lega, 2017-02-02
@lega

Does the kernel parse the function's source code and extract the argument names from it?

Yes
var foo = function($service1, $service2){}
foo.toString().match(/^[^\(]*\((.*)\)/)[1].split(',')
["$service1", " $service2"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question