无法解析 WinwheelService 的所有参数:(?,?)
Can't resolve all parameters for WinwheelService: (?, ?)
我有这样的 Winwheel 服务
@Injectable()
export class WinwheelService {
constructor(options, drawWheel) {}
}
然后我在我的应用程序组件中像这样初始化此服务
export class AppComponent implements AfterViewInit {
ngAfterViewInit() {
this.initWheel();
}
initWheel() {
this.wheel = new Winwheel({
'numSegments': 8, // Specify number of segments.
'outerRadius': 212, // Set radius to so wheel fits the background.
'innerRadius': 150, // Set inner radius to make wheel hollow.
'pointerAngle': 90,
'pointerGuide': // Turn pointer guide on.
{
'display': true,
'strokeStyle': 'red',
'lineWidth': 3
},
'segments': // Define segments including colour and text.
[
{ 'fillStyle': '#eae56f', 'text': 'Prize 1' },
{ 'fillStyle': '#89f26e', 'text': 'Prize 2' },
{ 'fillStyle': '#7de6ef', 'text': 'Prize 3' },
{ 'fillStyle': '#e7706f', 'text': 'Prize 4' },
{ 'fillStyle': '#eae56f', 'text': 'Prize 5' },
{ 'fillStyle': '#89f26e', 'text': 'Prize 6' },
{ 'fillStyle': '#7de6ef', 'text': 'Prize 7' },
{ 'fillStyle': '#e7706f', 'text': 'Prize 8' }
],
'animation': // Define spin to stop animation.
{
'type': 'spinToStop',
'duration': 5,
'spins': 8,
'callbackFinished': this.alertPrize()
}
}, true);
}
}
但是像这样初始化我的服务会出现以下错误
Can't resolve all parameters for WinwheelService: (?, ?)
用参数初始化 class 的另一种方法是什么。
由于我正在初始化我的服务对象 class,而不是将其注入到组件中,因此无需在应用程序模块的提供程序中注册它。
我有这样的 Winwheel 服务
@Injectable()
export class WinwheelService {
constructor(options, drawWheel) {}
}
然后我在我的应用程序组件中像这样初始化此服务
export class AppComponent implements AfterViewInit {
ngAfterViewInit() {
this.initWheel();
}
initWheel() {
this.wheel = new Winwheel({
'numSegments': 8, // Specify number of segments.
'outerRadius': 212, // Set radius to so wheel fits the background.
'innerRadius': 150, // Set inner radius to make wheel hollow.
'pointerAngle': 90,
'pointerGuide': // Turn pointer guide on.
{
'display': true,
'strokeStyle': 'red',
'lineWidth': 3
},
'segments': // Define segments including colour and text.
[
{ 'fillStyle': '#eae56f', 'text': 'Prize 1' },
{ 'fillStyle': '#89f26e', 'text': 'Prize 2' },
{ 'fillStyle': '#7de6ef', 'text': 'Prize 3' },
{ 'fillStyle': '#e7706f', 'text': 'Prize 4' },
{ 'fillStyle': '#eae56f', 'text': 'Prize 5' },
{ 'fillStyle': '#89f26e', 'text': 'Prize 6' },
{ 'fillStyle': '#7de6ef', 'text': 'Prize 7' },
{ 'fillStyle': '#e7706f', 'text': 'Prize 8' }
],
'animation': // Define spin to stop animation.
{
'type': 'spinToStop',
'duration': 5,
'spins': 8,
'callbackFinished': this.alertPrize()
}
}, true);
}
}
但是像这样初始化我的服务会出现以下错误
Can't resolve all parameters for WinwheelService: (?, ?)
用参数初始化 class 的另一种方法是什么。
由于我正在初始化我的服务对象 class,而不是将其注入到组件中,因此无需在应用程序模块的提供程序中注册它。