【发布时间】:2018-08-20 19:19:22
【问题描述】:
我在尝试构建 Angular 6 应用程序时遇到错误。
src/app/util/notification.service.ts(14,9) 中的错误:错误 TS1005: ':' 预期。
这里是相关代码
import { Injectable } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
@Injectable()
export class NotificationService {
timeOut: number = 5000;
constructor(private toastr: ToastrService) {}
error(toast_msg, msg_title){
this.toastr.error('<span class="now-ui-icons ui-1_bell-53"></span> ' + toast_msg, msg_title, {
this.timeOut
});
}
}
可能是什么问题?
【问题讨论】:
-
@JoelHarkes
super()为扩展其他类的类调用。至于 OP{this.timeOut}将不起作用,除非 两个变量具有完全相同的名称。并且timeout与this.timeOut不同:考虑明确声明它。
标签: angular typescript tslint