Answer the question
In order to leave comments, you need to log in
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 ButtonModule
in 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 { }
MedlibModule
that I will connect to the applicationimport { 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 { }
App
moduleimport { 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 { }
app.component.html
<app-button></app-button>
I should get a working component. 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. ...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question