我是Angular的新手。我正在学习配置块并运行模块块。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
});
正如你可以在配置块被写入看到:“你只能注入提供商(不是实例)”。
这是什么意思?任何人都可以解释提供者和实例之间有什么区别?
谢谢......它帮助我理解。 – RajSharma
不客气。 –