Saturday 15 August 2015

AngularJS - Difference in passing variables to functions -


One method passes through an array, another function; Is there a difference between the two? Depending on the situation should it be used on any other? What's the point in giving name to all the variables twice?

What is the correct word for passing in "variable", or is there a more specific word for AngularJS in these special types of variables?

  config (['$ routeProvider', function ($ route provider) {  

vs

  .config (function ( $ Route provider) If you want to shorten your code before deploying the output, then you can pass in the array {{code} 

. < / P>

Because the name of your parameter changes, and angular dependency depends on injection parameter names, if they meet (from '$ routeProvider' to 'a') it will not recognize it, so you Join the ray because the mining string will not change.

They both align equally, if you do not need, do not use the array method, but usually you do. ..

About the word "variable", it is more of a "injection" than a variable ... because I change it with a singleton, which is a function or an object or string Etc ...

No comments:

Post a Comment