Ionic 2:typescript:typescript:找不到名称'EventStaffLogService'
问题描述:
我遇到此错误。我已安装最新的应用程序脚本。我对打字稿不太了解,但是在我运行更新脚本之前,这已经习惯了。Ionic 2:typescript:typescript:找不到名称'EventStaffLogService'
CLI
$ ionic serve
Running 'serve:before' npm script before serve
> [email protected] watch C:\Users\cmadmin\Development\mobile\sportsinfocus-mobile-app
> ionic-app-scripts watch
[14:01:26] ionic-app-scripts 0.0.42
[14:01:26] watch started ...
[14:01:26] build dev started ...
[14:01:26] clean started ...
[14:01:26] clean finished in 6 ms
[14:01:26] copy started ...
[14:01:26] transpile started ...
[14:01:32] typescript: ...sportsinfocus-mobile-app/src/app/events/event-sign-in/event-sign-in.component.ts, line: 18
Cannot find name 'EventStaffLogService'.
event-sign-in.component.ts
事件登录in.component.ts
import { Component } from '@angular/core';
import { NavController, NavParams, ToastController } from 'ionic-angular';
import { EventStaffLogService, EventStaff } from '../shared/';
@Component({
templateUrl: 'event-sign-in.component.html',
providers: [EventStaffLogService]
})
export class EventSignInComponent {
eventStaff: any;
eventStaffLogs: Object = { data: [] };
fetchingLogs: Boolean = true;
isSignIn: Boolean = false;
constructor(
private navCtrl: NavController,
private navParams: NavParams,
private eventStaffLogService: EventStaffLogService,
public toastController: ToastController
) {
this.eventStaff = navParams.get('eventStaff');
this.getEventStaffLogs();
}
...
答
刚刚发现的问题。似乎从index.ts
文件导入会导致此错误。
从改变我的代码:
import { EventStaffLogService, EventStaff } from '../shared/';
到
import { EventStaffLogService } from '../shared/event-staff-log.service';
import { EventStaff } from '../shared/event-staff.model';
和它的工作。