M
M
microf2018-05-05 10:48:07
Angular
microf, 2018-05-05 10:48:07

How to connect the module correctly?

Something in the morning I have the basics, so to speak, angular did not come in.
I make a button component in angular-cli - ButtonComponent- I also make a module ButtonModulein which I export the button:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ButtonComponent } from './button.component';
@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [ButtonComponent],
  exports: [ButtonComponent]
})
export class ButtonModule { }

Next, I want to assemble this into another module MedlibModulethat I will connect to the application
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ButtonModule} from './button/button.module';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [
    ButtonModule
  ],
  exports: [ButtonModule, CommonModule]
})
export class MedlibModule { }

And here I am importing it into the Appmodule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {MedlibModule} from './medlib/medlib.module';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    MedlibModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

And it seemed to me that now by simply writing to app.component.html
<app-button></app-button>I should get a working component.
But I get
Uncaught Error: Template parse errors:
'app-button' is not a known element:
1. If 'app-button' is an Angular component, then verify that it is part of this module.
2. If 'app-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ...

Do not connect me every component in the app component. What did I miss?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question