Tôi đang cố nhập thành phần từ một tệp thành phần gốc khác. nó cho lỗi như ..Cách nhập thành phần vào thành phần gốc khác trong Angular 2
zone.js:484 Unhandled Promise rejection: Template parse errors: 'courses' is not a known element: 1. If 'courses' is an Angular component, then verify that it is part of this module. 2. If 'courses' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("
My First Angular 2 App
[ERROR ->]"): [email protected]:31 ; Zone: ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors: 'courses' is not a known element:
app.component.ts My giống như [file thành phần gốc]
import { Component } from '@angular/core';
import {CoursesComponent} from './courses.component';
@Component({
selector: 'my-app',
template: '<h1>My First Angular 2 App</h1><courses></courses>',
directives:[CoursesComponent],
})
export class AppComponent { }
và courses.component.ts tôi được;
import { Component } from '@angular/core';
@Component({
selector: 'courses',
template: '<h1>courses</h1>'
})
export class CoursesComponent { }
trong khi nhập khẩu các khóa học phần từ courses.component.ts nộp bên app.component tôi không phải là có thể khai báo chỉ thị bên @Component{}
directives:[CoursesComponent]
đưa ra lỗi với tôi
Xin cho biết giải pháp trên nó.
Bạn đang sử dụng phiên bản Angular2 nào? – micronyks