我最近开始学习angular2。尝试在学习在线教程的同时开发小型应用程序。我正面临一个错误,
Uncaught Error: Template parse errors: 'product' is not a known element:
1. If 'product' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.
ng:///AppModule/AppComponent.html@9:13
我的app.component.ts(在文件夹app中)
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `<product></product>`
})
export class AppComponent {
userText: string = 'Good Afternoon';
}
我的app.module.ts(在文件夹app中)
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
@NgModule({
imports: [BrowserModule, FormsModule, HttpModule,
RouterModule.forRoot(appRoutes)],
declarations: [AppComponent, HomeComponent],
bootstrap: [AppComponent],
providers: [EmployeeService]
})
export class AppModule { }
home.component.ts(在主文件夹中)
import { Component } from '@angular/core';
@Component({
selector: 'product',
templateUrl: './home.component.html'
})
export class HomeComponent {
title = 'Welcome!';
}
我想在home.component.html(在主文件夹中)创建html页面,并通过home.component.ts中的templateUrl链接它,并在选择器“product”的帮助下 我想通过绑定app.component.ts(在app文件夹中)将其显示出来。
请帮我解决这个问题。 谢谢。