angular.js - angular参数问题
高洛峰
高洛峰 2017-05-15 17:13:30
0
2
482

刚学习angular,很多地方不清楚,有个问题请教一下各位大神。
有一个入口函数的run方法,代码如下:


被红框圈出来的部分run和config里面有些参数,关于这些参数有两个地方不清楚:
问题1:这些参数是怎么确定的,为什么是这几个而不是其它的?名字是固定的吗,还是可以随意起?
问题2:这些参数是怎么传递过来的?

在具体的controller页面也一样有些参数不明白它是怎么传递的,代码截图如下:


和上面的两个疑问是一样的:
问题1:参数怎么确定的?
问题2:这些参数是怎么传递过来的?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
滿天的星座

1. Angular uses provide to create services (that is, things that can be injected, to put it bluntly, they are provided for other modules to use). A service can define a provider. Whenever you define a provider for a service, the name of the provider is is serviceProvider. Here service is the name of the service. The services corresponding to $httpProvider and $stateProvider in the above picture are $http, $state... These angular built-in services are defined by a serviceProvider at the bottom.

2. After defining the service, we need to use it in the module. To use the service, we first need to reference the dependency on the service, for example: app.controller('xxController', ['xxservice', function(xxservice) {xxx}]) Here xxController references xxservice and then uses it in the module. The bottom layer of angular uses inject to reference the services that modules depend on.

Some angular built-in services ($scope) in Figure 2 can be used without introducing them, and there is another service that needs to be referenced before use ($http, $state...)
You can refer to this article http:/ /sentsin.com/web/663.html

phpcn_u1582

The parameters you mentioned are all services to be injected. Inject those services you need. If these services are not used in your .run, .config, .controller, etc., you don’t need to write them.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!