简体   繁体   中英

1. If 'selector' is an Angular component, then verify that it is part of this module

I can't register my component. If I set

<app-actions-button></app-actions-button>

This is work good. But if I set

<app-actions-button (send)="some($event)"></app-actions-button>

i got error:

ERROR in src/app/test.component.html:162:1 - error NG8001: 'app-actions-button' is not a known element:

  1. If 'app-actions-button' is an Angular component, then verify that it is part of this module.
  2. If 'app-actions-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

Check my module:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ActionsButtonRoutingModule } from '../actions-button/actions-button-routing.module';
import { ActionsButtonComponent } from './actions-button.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ModalModule } from "ngx-bootstrap/modal";

@NgModule({
  declarations: [ActionsButtonComponent],
  imports: [
    CommonModule,
    ActionsButtonRoutingModule,
    FormsModule, ReactiveFormsModule,
    ActionsButtonComponent
  ],
  exports: [ActionsButtonComponent],
})
export class ActionsButtonModule { }

Your component app-actions-button dose not have an @Output property and it fails to compile.

You can read more on how to implement it here in the @Output Angular docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM