Prerendering failed because of error: ReferenceError: Event is not defined with PrimeNG AutoComplete

Prerendering failed because of error: ReferenceError: Event is not defined with PrimeNG AutoComplete

我正在尝试在我的 angular2 应用程序中使用 PrimgNG(primeng 2.0.5,Angular 2.0.x)。我可以让 ButtonModule 和 InputTextModule 工作,但不能让 AutoCompleteModule 工作。

我将 AutoCompleteModule 添加到应用程序后立即收到此错误。

An unhandled exception occurred while processing the request.

Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: Event is not defined

app.component.html:

<button pButton type="button" (click)="onclick()" >Click here</button>
<p-autoComplete [(ngModel)]="text" [suggestions]="results" (completeMethod)="search($event)"></p-autoComplete>

app.component.ts:

import { Component, OnInit } from '@angular/core';
import {ButtonModule, ToggleButtonModule} from 'primeng/primeng';

@Component({
   selector: 'app',
   templateUrl: './app.component.html',
   styleUrls: ['./app.component.css'],
})

export class AppComponent {
  text: string;
  results: string[];
  search(event){
    this.results = ['1','2','3'];
  }

  onclick():void{
    alert("This is a test");
  }
}

app.module.ts:

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { UniversalModule } from 'angular2-universal';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './components/app/app.component'
import {ButtonModule, AutoCompleteModule} from 'primeng/primeng';

@NgModule({
    bootstrap: [AppComponent],
    declarations: [
        AppComponent
    ],
    imports: [
        HttpModule,
        FormsModule,
        RouterModule.forRoot([
            { path: '', redirectTo: 'home', pathMatch: 'full' },
            { path: 'home', component: HomeComponent },
            { path: 'api-list', component: ApiListComponent },
            { path: 'api-add', component: ApiAddComponent },
            { path: '**', redirectTo: 'home', pathMatch: 'full' }
        ]),
        AutoCompleteModule,
        UniversalModule
    ]
})
export class AppModule {
}

如果我删除 AutoCompleteModule,一切正常。请帮忙。

我能够通过更改 Index.cshtml 页面中的 asp-prerender 标签来解决这个问题,该页面是由 ASP.Net Core Templates.I 生成的,但错过了关于 ASP.Net 我的问题的核心模板。

我从

更改了标签
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>

<app asp-ng2-prerender-module="ClientApp/dist/main-server">Loading...</app>

直接取消预渲染。

<app>Loading...</app>

几周前我在 Whosebug 上找到了这个答案,试图再次搜索到 link,但没有得到任何结果。如果有人找到它,请在此处link。谢谢

使用以下步骤

1. "Loading..."

2. In Browser.ts file or boot.client.ts file import the following **import es6-shim**