如果'event-component'是Angular组件,则验证它是否是此模块的一部分

时间:2019-03-10 15:53:29

标签: angular ionic-framework

我有以下错误:

如果“事件组件”是Angular组件并且具有“事件”输入,则请验证它是否属于此模块

这是我的组件:

import { Component, OnInit,Input, Output, EventEmitter } from '@angular/core';
import { Event } from '../../../providers/sharedTypes';


@Component({
  selector: 'event-component',
  templateUrl: './events.component.html',
  styleUrls: ['./events.component.scss'],
})
export class EventsComponent implements OnInit {
  @Input('Events') Events:Array<Event>;
  text: string;

  constructor() { }

  ngOnInit() {}

}

这是我拥有组件的页面:

<ion-header>
  <ion-toolbar>
    <ion-title>
      Feel
    </ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>

  <event-component [Events]="EventsLoad"></event-component>

</ion-content>

这是在我的app.component.spec.ts中:

TestBed.configureTestingModule({
      declarations: [AppComponent,EventsComponent],
      schemas: [CUSTOM_ELEMENTS_SCHEMA]

这是在我的app.module.ts中:

@NgModule({
  declarations: [
    AppComponent,
    EventsComponent
  ],
  entryComponents: [EventsComponent],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,HttpModule

为什么会出现这些错误?

我在哪里错了?

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

这里是完整的消息:

Can't bind to 'Events' since it isn't a known property of 'event-component'.
1. If 'event-component' is an Angular component and it has 'Events' input, then verify that it is part of this module.
2. If 'event-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-content>

  <event-component *ngIf="EventsLoad" [ERROR ->][Events]="EventsLoad"></event-component>

</ion-content>
"): ng:///Tab1PageModule/Tab1Page.html@10:38
'event-component' is not a known element:
1. If 'event-component' is an Angular component, then verify that it is part of this module.
2. If 'event-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-content>

  [ERROR ->]<event-component *ngIf="EventsLoad" [Events]="EventsLoad"></event-component>

</ion-content>
"): ng:///Tab1PageModule/Tab1Page.html@10:2
Error: Template parse errors:
Can't bind to 'Events' since it isn't a known property of 'event-component'.
1. If 'event-component' is an Angular component and it has 'Events' input, then verify that it is part of this module.
2. If 'event-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-content>

  <event-component *ngIf="EventsLoad" [ERROR ->][Events]="EventsLoad"></event-component>

</ion-content>
"): ng:///Tab1PageModule/Tab1Page.html@10:38
'event-component' is not a known element:
1. If 'event-component' is an Angular component, then verify that it is part of this module.
2. If 'event-component' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-content>

  [ERROR ->]<event-component *ngIf="EventsLoad" [Events]="EventsLoad"></event-component>

</ion-content>
"): ng:///Tab1PageModule/Tab1Page.html@10:2
    at syntaxError (compiler.js:2430)
    at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:20604)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:26167)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:26154)
    at compiler.js:26097
    at Set.forEach (<anonymous>)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:26097)
    at compiler.js:26007
    at Object.then (compiler.js:2421)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:26006)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:17289)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)
defaultErrorLogger @ core.js:15723