core.js:6228错误TypeError:ctx。 Viewplayerpage不是功能

时间:2020-06-23 06:48:52

标签: angular ionic-framework

这是我的tab1.html代码:

  <ion-header [translucent]="true">
  <ion-toolbar>
  <ion-buttons slot="start">
      <ion-button >
        <ion-icon class="icon-dis" name="options-outline"></ion-icon>
      </ion-button>
      </ion-buttons>  
  <ion-title> Dashboard</ion-title>
  <ion-buttons slot="end" (click)="viewpageplayer()" >
  <ion-button >
    <ion-icon class="icon-dis" name="add-circle"></ion-icon>
  </ion-button>
  </ion-buttons>
  </ion-toolbar>
  </ion-header>

这是我的tab1.page.ts代码

  import { Component } from '@angular/core';
  import { ModalController } from '@ionic/angular';
  import { Router } from '@angular/router';
  import { ViewPlayerPagePageModule } from '../view-player-page/view-player-page.module';


  @Component({
   selector: 'app-tab1',
    templateUrl: 'tab1.page.html',
    styleUrls: ['tab1.page.scss']
   })
  export class Tab1Page  {


   constructor(public viewCtrl: ModalController,
   public router: Router,  public modalController: ModalController) { }


   async openModal() {
   const modal = await this.modalController.create({
   component: ViewPlayerPagePageModule,
   cssClass :"viewPlayerPage"
   });
    return await modal.present();
    }

  }

这是app.modal.ts代码。我已将viewplayerpage导入到app.moda.ts文件中。

 import { NgModule } from '@angular/core';
 import { BrowserModule } from '@angular/platform-browser';
 import { RouteReuseStrategy } from '@angular/router';

 import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
 import { SplashScreen } from '@ionic-native/splash-screen/ngx';
 import { StatusBar } from '@ionic-native/status-bar/ngx';

 import { AppRoutingModule } from './app-routing.module';
 import { AppComponent } from './app.component';
 import { ForgotPasswordPage } from './forgot-password/forgot- 
 password.page';
 import { CreateclassPage } from './createclass/createclass.page';
 import { ViewPlayerPagePageModule } from './view-player-page/view- 
 player-page.module';
 @NgModule({
 declarations: [AppComponent, ForgotPasswordPage, CreateclassPage],
  entryComponents: [ForgotPasswordPage, CreateclassPage],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, 
 ViewPlayerPagePageModule],
 providers: [
  StatusBar,
  SplashScreen,
  { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
 bootstrap: [AppComponent],
 })
 export class AppModule {}

我已经运行了上面的代码,但出现以下错误:

 core.js:6228 ERROR TypeError: ctx.viewpageplayer is not a function
at Tab1Page_Template_ion_buttons_click_7_listener (template.html:9)
at executeListenerWithErrorHandling (core.js:21806)
at wrapListenerIn_markDirtyAndPreventDefault (core.js:21848)
at HTMLElement.<anonymous> (platform-browser.js:976)
at ZoneDelegate.invokeTask (zone-evergreen.js:399)
at Object.onInvokeTask (core.js:41632)
at ZoneDelegate.invokeTask (zone-evergreen.js:398)
at Zone.runTask (zone-evergreen.js:167)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)
at invokeTask (zone-evergreen.js:1621)

我是Ionic的新手,正在使用模态视图page.got错误,如上所示。如果有人可以在这方面帮助我,那将是很好。预先感谢。

1 个答案:

答案 0 :(得分:0)

尝试在组件控制器中定义事件处理程序viewpageplayer()

tab1.page.ts

export class Tab1Page  {
  ...

  viewpageplayer() {
    console.log('button clicked');
    // do something
  }
}