【发布时间】:2016-12-14 23:44:06
【问题描述】:
我是 Angular 的新手。我正在研究模块的配置块和运行块。
请看下面的代码:
angular.module('myModule', []).
config(function(injectables) { // provider-injector
// This is an example of config block.
// You can have as many of these as you want.
// You can only inject Providers (not instances)
// into config blocks.
}).
run(function(injectables) { // instance-injector
// This is an example of a run block.
// You can have as many of these as you want.
// You can only inject instances (not Providers)
// into run blocks
});
正如您在配置块中看到的那样,它是这样写的:“您只能注入提供者(而不是实例)”。
这是什么意思?谁能解释一下提供者和实例之间的区别是什么?
【问题讨论】:
标签: javascript angularjs module config