Angular 复习与进阶系列 – Naming Conversion

发布时间 2023-04-07 15:00:37作者: 兴杰

前言

命名规范对项目维护是很重要的. Angular 对项目的渗透很大的, 必须做好命名规范, 不然会很乱.

 

Angular Naming Conversion

InjectionToken = UPPER_SNAKE_CARE

const SERVICE_CONFIG_TOKEN = new InjectionToken('ServiceConfig');

 

element attribute and property name = camelCase

angular.io example 有 camelCase 和 kebab-case, 不过我看绝大部分都是用 camelCase 居多.

<bank-account bankName="RBC" account-id="4747"></bank-account>

 

event handler method

如果没有一个具体的名字, 不要放 (click)="onClick()" 放 "handleClick()"

 

from material