![](/img/trans.png)
[英]Mean Stack: How can I store image in mongodb with nodejs expressjs and angular 6?
[英]Angular 2 - MEAN MongoDB NodeJS
我正在使用这个GitHub示例( https://github.com/bradtraversy/mean_mytasklist ),它到目前为止工作正常。 我看到我的MongoDB的任务,可以添加,删除任务。
然后我试图添加一个新组件“标题”
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'headers',
templateUrl: 'header.component.html'
})
export class HeaderComponent {
}
我在app.modules.ts中添加了这个组件
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { TasksComponent } from './components/tasks/tasks.component';
import { HeaderComponent } from './components/header/header.component';
@NgModule({
imports: [BrowserModule, HttpModule, FormsModule],
declarations: [AppComponent, TasksComponent, HeaderComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
在我的app.component.html中,我正在使用此选择器。
<div class="container">
<headers></headers>
<h1>MyTaskList</h1>
<hr>
<tasks></tasks>
</div>
刷新浏览器后,我会收到以下错误消息:
zone.js:420未处理的Promise拒绝:模板解析错误:'headers'不是已知元素:1。如果'headers'是Angular组件,则验证它是否是此模块的一部分。 2.如果'headers'是Web组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到此组件的'@NgModule.schemas'以禁止显示此消息。 (“[错误 - >]
<headers></headers>
<h1>MyTaskList</h1>
<hr>
有任何想法吗? 非常感谢!!!
“):AppComponent @ 1:4;区域:;任务:Promise.then;
您正在使用哪个版本的Angular 2并且您没有使用webpack进行构建?
错误控制台本身提到了解决方案。 你需要添加
schemas: [CUSTOM_ELEMENTS_SCHEMA ]
所以你的app.module.ts应该是这样的,
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@NgModule({
imports: [BrowserModule, HttpModule, FormsModule],
declarations: [AppComponent, TasksComponent, HeaderComponent],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA ]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.