私はウェブプロジェクトを使用し、角度2を使用していますクリックイベントを使用した別のページは問題ありませんが、新しいページが作成された後、イベントをクリックすると新しいページでエラーが発生します。角2のクリックイベントが機能しない
このエラー
TypeError: self.parentView.parentView.context.changedItem is not a function at View_SiteConfig3.handleEvent_0 (/AppModule/SiteConfig/component.ngfactory.js:137) at View_SiteConfig3.eval (core.umd.js:12399) at HTMLTextAreaElement.eval (platform-browser.umd.js:3223) at ZoneDelegate.invokeTask (zone.js:265) at Object.onInvokeTask (core.umd.js:3971) at ZoneDelegate.invokeTask (zone.js:264) at Zone.runTask (zone.js:154) at HTMLTextAreaElement.ZoneTask.invoke (zone.js:335)
サイトconfig.html
<div *ngFor="let item of items1; let i = index;" class="col-sm-4">
<button (click)="changedItem(item)">Test</button>
</div>
サイトconfig.ts
import { Component, OnInit } from '@angular/core'
import { Http } from '@angular/http'
@Component({
selector: 'site-config',
moduleId: module.id,
templateUrl: '/site-config.html'
})
export class SiteConfig implements OnInit {
items1: number[] = [1,2,3]
ngOnInit(): void {
}
public changedItem(item) {
//My Codes This Here
}
constructor(private http: Http) {
}
}
EDIT:この問題を解決しました。
My project worked. Problem is ts file not compiled then give a "is not a function" error
changedItemメソッドを公開できますか? –
changedItemメソッドのみが動作せず、app.tsファイルなしで上記のすべてのコード –