2017-09-19 4 views
0

私はこのエラーが出る角度4でクラスをインスタンス化しよう:角度インスタンス化クラスエラー

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

次のような種々のStackOverflowの答えは、私は別のevent.tsを試してみましたが、それは同じエラー生成:それはいいものに声明

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

Eventクラスで

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

答えて

1

ルックとを。 Angular'sまたはJavascriptのEventクラスと混同される可能性があります。

関連する問題