Bishan
Bishan

Reputation: 15702

error TS1005: ':' expected TypeScript Angular6

I am getting below error when trying to build my Angular 6 app.

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

Here is the related code

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

}

What could be the issue?

Upvotes: 3

Views: 2323

Answers (3)

Suren Srapyan
Suren Srapyan

Reputation: 68635

Error is related to TypeScript configuration.

Create your object by explicitly giving property name

{ timeout: this.timeOut }

Upvotes: 3

Aniket Avhad
Aniket Avhad

Reputation: 4145

Issue with you are not using key value pair for timeOut

Try this,

error(toast_msg, msg_title) {
        this.toastr.error('<span class="now-ui-icons ui-1_bell-53"></span> ' + toast_msg, msg_title, {
            timeOut: this.timeOut
        });
    }

Upvotes: 1

Andrei Tătar
Andrei Tătar

Reputation: 8295

You probably want something like:

this.toastr.error('<span class="now-ui-icons ui-1_bell-53"></span> ' + toast_msg, msg_title, {
  timeout: this.timeOut,
});

or, since rest of the parameters are passed as args:

this.toastr.error('<span class="now-ui-icons ui-1_bell-53"></span> ' + toast_msg, msg_title, this.timeOut);

Upvotes: 7

Related Questions