我是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
不客氣。 –