0
我試着去了解怎麼樣了供應商的作品,我讓基於angularjs文檔中的一個測試,我寫了一個簡單的供應商:
(function(window, angular, undefined){"use strict";
function MyProviderExample(foo)
{
this.testdrive = function()
{
console.log(foo);
}
console.log("init");
}
angular.module('app',[])
.provider('$myProvider',function(){
var foo = "bar";
this.$get = function()
{
return new MyProviderExample(foo);
}
console.log("ey....");
}).config(function($myProvider){
console.log("wut");
$myProvider.foo = "foo";
});
})(window, window.angular);
當我始終運行的代碼返回
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: $myProvider
我試圖理解失敗,但我看不到我的錯,如果有人能幫助我欣賞