我有一个注册页面模块,我试图在其中包括一个自定义组件:“ EaterSignUpModule”(很快将成为一个具有两个自定义组件的模块,用于不同的用户角色)
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { SignupPage } from './signup';
// components
import { EaterSignupModule } from './components/eater-signup/eater_signup.module';
// services
import { SignUpService } from './services/signup.service';
@NgModule({
declarations: [
SignupPage,
],
imports: [
IonicPageModule.forChild(SignupPage),
EaterSignupModule
],
exports: [
SignupPage
],
providers: [
SignUpService
]
})
export class SignupPageModule { }
这是我的自定义组件的模块文件:
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
// components
import { EaterSignUp } from './eater_signup';
// services
import { SignUpService } from '../../services/signup.service';
@NgModule({
declarations: [
EaterSignUp
],
imports: [
IonicModule,
],
exports: [
EaterSignUp
],
entryComponents: [
EaterSignUp
],
providers: [
SignUpService
]
})
export class EaterSignupModule { }
这是组件打字稿文件/类文件:
import { Component } from '@angular/core';
import { AlertController, App, LoadingController } from 'ionic-angular';
// interfaces
import { Credentials,
EaterProfile,
VendorProfile,
VehicleDimensions
} from '../../../../interfaces/main.interfaces';
// services
import { SignUpService } from '../../services/signup.service';
@Component({
selector: 'eater-signup',
templateUrl: 'eater_signup.html',
})
export class EaterSignUp {
constructor(
public loadingCtrl: LoadingController,
public alertCtrl: AlertController,
public signUpService: SignUpService,
public app: App
) {
this.initialize();
}
public initialize(){
}
}
我实际使用选择器的位置的代码:
<ng-container *ngIf="viewState=='eaterSelected'">
<eater-signup></eater-signup>
</ng-container>
我对在离子中做这种事情的理解受到限制(IonicPage和IonicPage模块)
我遇到以下错误:“未捕获的错误:模板解析错误: “食客注册”不是一个已知元素: 1.如果'eater-signup'是Angular组件,请验证它是否是此模块的一部分.....“”
在正常角度下,我通常只声明该组件,甚至不需要模块。
希望对此有所帮助。谢谢