Tôi là người mới trong Angular2. Tôi đã cố gắng tạo một thành phần nhưng hiển thị một lỗi.
Đây là app.component.ts
tập tin.
import { Component } from '@angular/core';
import { MyComponentComponent } from './my-component.component';
@Component({
selector: 'my-app',
template: `
<h1>Hello {{name}}</h1>
<h4>Something</h4>
<my-component></my-component>
`,
directives: [MyComponentComponent]
})
export class AppComponent { name = 'Sam' }
Đây là thành phần mà tôi muốn tạo.
import { Component } from '@angular/core';
@Component({
selector: 'my-component',
template: `
<p>This is my article</p>
`
})
export class MyComponentComponent {
}
Hiển thị hai lỗi:
- Nếu
my-component
là một thành phần Angular, thì xác minh rằng nó là một phần của mô-đun này. - Nếu
my-component
là Thành phần Web thì thêmCUSTOM_ELEMENTS_SCHEMA
vào@NgModule.schemas
thành phần này để chặn thông báo này.
Xin vui lòng giúp đỡ.