angular - 错误 TS1005:“:”预期 TypeScript Angular6
问题描述
尝试构建我的 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
});
}
}
可能是什么问题?
解决方案
你可能想要这样的东西:
this.toastr.error('<span class="now-ui-icons ui-1_bell-53"></span> ' + toast_msg, msg_title, {
timeout: this.timeOut,
});
或者,因为其余参数作为 args 传递:
this.toastr.error('<span class="now-ui-icons ui-1_bell-53"></span> ' + toast_msg, msg_title, this.timeOut);
推荐阅读
- mysql - 如何将数据从一列行复制到同一列但不同的行
- angular - 在生产中更改 Angular 应用程序中的服务器 IP
- json - JQ:从数字对象中选择键
- vba - 如何在 VBA 中过滤减去 XX 个工作日?
- wicket - Wicket 获取按钮组件文本
- c# - IClientProxy.SendAsync 字符串方法参数中还有哪些其他选项?
- .net - 如何将附件添加到具有 (PDF/A-3) 文件格式的 pdf 文件?
- node.js - 如何在 NodeJS、Express、Mongoose 应用程序中为 Model.findOne 的回调函数定义全局变量?
- php - 用数字和文本替换数组
- mongodb - 在 mongoDB 中查找特定字段的最新数据