0

When I try to instantiate a class in Angular 4 I get this error:

Supplied parameters do not match any signature of call target

admin.component.ts:

import { Component } from '@angular/core';
import { Event } from '../event';

@Component({
  selector: 'app-admin',
  templateUrl: './admin.component.html',
})
export class AdminComponent {
  onSubmit() { 
    const event = new Event('foo', 'bar');
  }
}

event.ts:

export class Event {
    constructor(
        public event: string,
        public comments: string
    ) { }
}

Following various StackOverflow answers I tried a different event.ts but it produced the same error:

export class Event {
    event: string;
    readableDate: string;
    constructor(public event: string, public readableDate: string) {
        this.event = event;
        this.readableDate = readableDate;
    }
}

1 Answer 1

1

Look at the Event class in the statement

const event = new Event('foo', 'bar');

and to which one it refers. It may be confused with Angular's or Javascript's Event class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.