我正在实现一个 angular 4 组件并出现错误
如果 'footer-bar' 是一个 Angular 组件,那么验证它是否是这个模块的一部分。如果 'nav-bar' 是一个 Angular 组件,那么验证它是否是这个模块的一部分。
我已经在 app.module 中导入了工具栏和导航栏。不知道为什么我收到错误
导航栏
import { Component, OnInit } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'nav-bar',
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.css']
})
export class NavbarComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
页脚栏
import { Component, OnInit } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'footer-bar',
templateUrl: './footerbar.component.html',
styleUrls: ['./footerbar.component.css']
})
export class FooterbarComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
Run Code Online (Sandbox Code Playgroud)
应用模块
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http'
import { AppComponent } from './app.component';
import { NavbarComponent } from './navbar/navbar.component';
import { TopbarComponent } from './topbar/topbar.component';
import { FooterbarComponent } from './footerbar/footerbar.component';
import { MRDBGlobalConstants } from './shared/mrdb.global.constants';
@NgModule({
declarations: [
AppComponent,
FooterbarComponent,
TopbarComponent,
NavbarComponent
],
imports: [
BrowserModule,
HttpModule
],
providers: [MRDBGlobalConstants],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
应用组件
import { Component ,ViewContainerRef } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
constructor(public viewRef : ViewContainerRef) {
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13030 次 |
| 最近记录: |