Javascript 无法将服务注入控制器
我编写了一个服务(空的,只是为了测试),我想将其注入控制器 然而,不幸的是,这不起作用,我看不出问题所在 这是我的密码:Javascript 无法将服务注入控制器,javascript,angularjs,ionic,Javascript,Angularjs,Ionic,我编写了一个服务(空的,只是为了测试),我想将其注入控制器 然而,不幸的是,这不起作用,我看不出问题所在 这是我的密码: app.controller('AppCtrl', function($scope, $location, Test){ $scope.goto = function(destination){ $location.path(destination); } }) app.service('Test', ['', function(){ }]) 这里有
app.controller('AppCtrl', function($scope, $location, Test){
$scope.goto = function(destination){
$location.path(destination);
}
})
app.service('Test', ['', function(){
}])
这里有一个例外:
Error: [$injector:unpr] Unknown provider: Provider <- <- Test
http://errors.angularjs.org/1.3.13/$injector/unpr?p0=Provider%20%3C-%20%20%3C-%20Test
at REGEX_STRING_REGEXP (ionic.bundle.js:8890)
at ionic.bundle.js:12824
at Object.getService [as get] (ionic.bundle.js:12971)
at ionic.bundle.js:12829
at getService (ionic.bundle.js:12971)
at invoke (ionic.bundle.js:13003)
at Object.instantiate (ionic.bundle.js:13020)
at Object.<anonymous> (ionic.bundle.js:12881)
at Object.invoke (ionic.bundle.js:13012)
at Object.enforcedReturnValue [as $get] (ionic.bundle.js:12865)
错误:[$injector:unpr]未知提供程序:提供程序您正在注入'
的依赖项,因此Angular告诉您它找不到该提供程序
相反,只需:
app.service('Test', function(){
});
您正在注入一个'
的依赖项,因此Angular告诉您它找不到该提供者
相反,只需:
app.service('Test', function(){
});
空字符串'
空字符串'