为什么我有这样的错误:
AboutComponent_Host.ngfactory.js? [sm]:1 ERROR Error: The selector "app-about" did not match any elements
at DefaultDomRenderer2.webpackJsonp.../../../platform-browser/esm5/platform-browser.js.DefaultDomRenderer2.selectRootElement (platform-browser.js:2805)
at BaseAnimationRenderer.webpackJsonp.../../../platform-browser/esm5/animations.js.BaseAnimationRenderer.selectRootElement (animations.js:495)
at DebugRenderer2.webpackJsonp.../../../core/esm5/core.js.DebugRenderer2.selectRootElement (core.js:15257)
at createElement (core.js:10531)
at createViewNodes (core.js:13688)
at createRootView (core.js:13616)
at callWithDebugContext (core.js:15041)
at Object.debugCreateRootView [as createRootView] (core.js:14324)
at ComponentFactory_.webpackJsonp.../../../core/esm5/core.js.ComponentFactory_.create (core.js:11218)
at ComponentFactoryBoundToModule.webpackJsonp.../../../core/esm5/core.js.ComponentFactoryBoundToModule.create (core.js:4011)
我的代码:
约/ about.component.html:
<div class="signin-content" >
<mat-card >
<mat-card-content></mat-card-content>
</mat-card>
</div>
约/ about.component.ts:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-about',
templateUrl: './about.component.html',
styleUrls: ['./about.component.css']
})
export class AboutComponent implements OnInit {
constructor() { }
ngOnInit() {}
}
我应该在哪里添加&#39; app-about&#39; ?
来源&#39;标签,突出显示我:
<app-about></app-about>
答案 0 :(得分:0)
是:
app.moduls.ts:
import {BrowserModule} from '@angular/platform-browser';
import {NgModule, NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import {AppRoutingModule} from './app-routing.module';
import {ReactiveFormsModule} from '@angular/forms';
import {AppComponent} from './app.component';
import {HomeComponent} from './home/home.component';
import {LoginComponent} from './login/login.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {AppMaterialModule} from './app-material/app-material.module';
import {FormsModule} from '@angular/forms';
import {AboutComponent} from './about/about.component';
import {AuthService} from './auth/auth.service';
import {AuthGuard} from './auth/auth.guard';
import {HttpModule} from '@angular/http';
import './rxjs-operators';
import {RegistrationComponent} from './registration/registration.component';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
AboutComponent,
LoginComponent,
RegistrationComponent
],
imports: [
BrowserModule,
AppRoutingModule,
ReactiveFormsModule,
BrowserAnimationsModule,
AppMaterialModule,
FormsModule,
HttpModule
],
providers: [AuthService, AuthGuard],
bootstrap: [AppComponent, AboutComponent]
})
export class AppModule {}