小编Mar*_*ler的帖子

无法将服务注入控制器

我写了一个服务(空的,仅用于测试目的),我想将其注入控制器.

但是,遗憾的是这不起作用,我看不出问题.

这是我的代码:

app.controller('AppCtrl', function($scope, $location, Test){

  $scope.goto = function(destination){
    $location.path(destination);
  }

})

app.service('Test', ['', function(){

}])
Run Code Online (Sandbox Code Playgroud)

这是例外:

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)
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚这个问题

javascript angularjs ionic

1
推荐指数
1
解决办法
199
查看次数

标签 统计

angularjs ×1

ionic ×1

javascript ×1