编辑器
语法参考
组件装饰器
@Component({ selector, templateUrl, styleUrls })
@Directive({ selector })
@Pipe({ name, pure })
@Injectable({ providedIn: 'root' })
模板语法
{{ property }} — 插值
[property]="expression" — 属性绑定
(event)="handler()" — 事件绑定
@if (condition) { ... } @else { ... }
@for (item of list; track item.id) { ... }
@switch (value) { @case (1) { ... } }
依赖注入
constructor(private svc: Service) {}
inject(Service) — 函数式注入
@Input() / @Output() — 输入输出
@ViewChild('ref') — 获取子组件
@ViewChildren — 获取多个子组件
@ContentChild — 获取投影内容
生命周期
ngOnInit() — 初始化
ngOnChanges(changes) — 输入变化
ngAfterViewInit() — 视图就绪
ngOnDestroy() — 销毁清理