Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always got 'Cannot read property 'selector' of null' error in ionic4 project, even new project #68

Closed
gulullu opened this issue Oct 22, 2018 · 2 comments

Comments

@gulullu
Copy link

gulullu commented Oct 22, 2018

image

whre use it:

import { Component } from '@angular/core';
import { Toast } from 'ng-zorro-antd-mobile';

@Component({
  selector: 'app-about',
  templateUrl: 'about.page.html',
  styleUrls: ['about.page.scss']
})
export class AboutPage {
  test() {
    const toast = Toast.loading('Loading...', 3000, () => {
      console.log('Load complete !!!');
    });
  }
}

app.module.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 { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { NgZorroAntdMobileModule, ToastComponent } from 'ng-zorro-antd-mobile';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [ToastComponent],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,
    BrowserAnimationsModule, FormsModule, HttpClientModule, NgZorroAntdMobileModule],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

ionic info:

Ionic:

   ionic (Ionic CLI)          : 4.1.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.13
   @angular-devkit/core       : 0.8.6
   @angular-devkit/schematics : 0.8.6
   @angular/cli               : 6.2.6
   @ionic/ng-toolkit          : not installed
   @ionic/schematics-angular  : not installed

System:

   NodeJS : v8.12.0 (/Users/Allen/.nvm/versions/node/v8.12.0/bin/node)
   npm    : 6.4.1
   OS     : macOS

Environment:

   http_proxy  : http://127.0.0.1:6152
   https_proxy : http://127.0.0.1:6152
@gulullu gulullu changed the title always got 'Cannot read property 'selector' of null' in ionic4 project, even new project always got 'Cannot read property 'selector' of null' error in ionic4 project, even new project Oct 22, 2018
@nuonuoge
Copy link
Collaborator

nuonuoge commented Oct 22, 2018

http://ng.mobile.ant.design/#/components/toast/zh

import { Component } from '@angular/core';
import { Toast } from 'ng-zorro-antd-mobile';
@Component({
  selector: 'demo-toast-basic',
  template: `
  `,
  providers: [Toast]  // you lost
})

export class DemoToastBasicComponent {
  constructor(private _toast: Toast) {}  // you lost
}

app.module.ts sholud add entryComponents

entryComponents: [ToastComponent]

@gulullu
Copy link
Author

gulullu commented Oct 23, 2018

http://ng.mobile.ant.design/#/components/toast/zh

import { Component } from '@angular/core';
import { Toast } from 'ng-zorro-antd-mobile';
@Component({
  selector: 'demo-toast-basic',
  template: `
  `,
  providers: [Toast]  // you lost
})

export class DemoToastBasicComponent {
  constructor(private _toast: Toast) {}  // you lost
}

app.module.ts sholud add entryComponents

entryComponents: [ToastComponent]

Thanks!

@gulullu gulullu closed this as completed Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants