我简略搜索了下,实现原理好像并不是和 ngStyle 这种类似。在源码中看到一个枚举类型,这个是不是指的是 property (类似 ngStyle )和 [style.rule] 完全是两套机制?
文件是 template_ast.ts
export const enum PropertyBindingType {
// A normal binding to a property (e.g. `[property]="expression"`).
Property,
// A binding to an element attribute (e.g. `[attr.name]="expression"`).
Attribute,
// A binding to a CSS class (e.g. `[class.name]="condition"`).
Class,
// A binding to a style rule (e.g. `[style.rule]="expression"`).
Style,
// A binding to an animation reference (e.g. `[animate.key]="expression"`).
Animation,
}
最后我只能说,这个 TM 根本不是指令...这个是一套单独的解析。难怪查指令大多都是 ngStyle 的内容了