angular - 错误 TS1005 : ':' expected TypeScript Angular6

标签 angular typescript tslint

我在尝试构建我的 Angular 6 应用程序时遇到错误。

ERROR in src/app/util/notification.service.ts(14,9): error TS1005: ':' expected.

相关代码如下

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);

关于angular - 错误 TS1005 : ':' expected TypeScript Angular6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51929373/

相关文章:

javascript - 在自定义钩子(Hook)中测试 fetch.catch

tslint - ng lint 中预期的空格缩进

css - 如何CSS选择Angular-Material表tbody?

angular - ng build --prod = 无法设置未定义的属性 '_autoActivated'

javascript - 无法匹配任何路线。带参数的 Angular2 URL

reactjs - 在 Emotion 11/Next js 10 应用程序中启用 css Prop 的正确方法是什么

angular - 在应用程序组件以外的组件中使用 <router-outlet>?

typescript - 定义相互递归的 zod 模式

angular - angular指令选择器与tslint的冲突

angular - TSLINT 配置 : exclude external modules