In the ANGULARJS official documentation about the configuration of $routeprovider, there is a phrase for template and Templateurl configuration
If it is a function, it'll be called with the following Parameters:{array.<object>}-route parameters extracted F Rom the Current$location.path () by applying the current route
It is not easy to understand what it means to read it quite a mouthful.
In a nutshell, the value of the template and Temlateurl can be a function that takes parameters and returns a URL for an HTML script and an HTML script file, respectively. The case with no parameters is simple, and the corresponding data can be returned. What about the parameters, and what are the parameters? The above mentioned is the route parameters (route parameter). At first, I thought it was $routeparams, so we took $routeparams as a parameter. In fact, when defining a function, the arguments we pass are actually formal parameters. Where does the argument come from? This function is actually executed in the background and is passed by Angularjs to the function, and of course we need to set the parameters in the function in order to reference the arguments. How did the argument come from? The $location.path () of the current route is mentioned above. In the path configuration fragment, it is mentioned that if the path parameter is used with a named group (named Group), its parameters are extracted and stored in $routeparams. The parameter that is extracted in path is our argument here.
Look at the code:
<! doctype html>After execution, you can output {"Test": "1"} in the console.
The scope of the problem ($scope. URL) is also shown earlier in this section. And the application of global function re-angularjs.
This article is from the "formeforyou" blog, make sure to keep this source http://tancfeng.blog.51cto.com/4079342/1727699
Angularjs $routeProvider template function and parameter doubts