我正在学习 Angular 数据绑定概念并开始尝试使用 StackBlitz。
这是我的,
main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import 'zone.js';
import { BindingModule } from './binding/binding.module';
bootstrapApplication(BindingModule);
绑定.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { BindingComponent } from './binding.component';
@NgModule({
imports: [CommonModule, BrowserModule],
declarations: [BindingComponent],
bootstrap: [BindingComponent],
})
export class BindingModule {}
绑定.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-binding',
templateUrl: './binding.component.html',
styleUrls: ['./binding.component.css']
})
export class BindingComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
我有一个 HTML
<p>
要打印,装订有效!
但我最终遇到以下错误:
错误:NG0906:BindingModule 不是 Angular 组件,请确保它具有
装饰器。@Component
请帮忙!
您的项目结构看起来与平常有点不同。我不是角度专家,但你是否尝试使用“ng new”命令创建项目并再次尝试