【发布时间】:2023-03-16 05:37:02
【问题描述】:
我有一个名为 Example 的服务,我在 angular 1 应用程序中使用了它。它具有 angular 1 依赖项$resource, $http, $q,我想在我的 angular 2 服务中使用它。
但下面是我尝试实施升级的方式。
var ExampleService = require('./service.js');
angular.module('angular-legacy',[]).service('example', ExampleService);
upgradeAdapter.upgradeNg1Provider('example');
var AppComponent =
ng.core.Component({
selector: 'app',
providers: [ExampleService]
})
.View({
template: ' <div>Hello </div> ',
})
.Class({
constructor: [ExampleService, function (service) {
console.log(service);
}]
});
我在这些方面遇到了错误。
cannot resolve all parameters for 'ExampleService'(?, ?, ?, ?, ?).
有没有办法注入升级版的 ExampleService?
【问题讨论】:
-
请参阅"Should questions include “tags” in their titles?",其中的共识是“不,他们不应该”!
标签: javascript angularjs angular