I have detected some inconsistencies between the code examples and the official style guide. Here are my findings and suggestions:
Filenames
I've seen examples of a component called ChildComponent and the name of the file being child.ts. In that case the filename should be child.component.ts.
Instead of naming the root module as example.module.ts we should follow the convention an name it app.module.ts.
Instead of naming the root component index.html we should follow the convention and name it app.component.ts.
Every component name should end with the suffix Component so instead of naming a component like:
To avoid confusing students with the import paths, I think we should be more explicit and instead of doing import { AppComponent, ChildComponent } from './'; do:
import { AppComponent } from './app.component';
import { ChildComponent } from './child.component';
Selectors
To avoid collisions, it's a good practice to always apply a prefix to all the selectors for components and directives, in this case rio-. So instead of having app-root use rio-app.
Module Decorator Properties
There's not an official recommendation about this, but every example that I see in angular.io declare the properties of the NgModule decorator in this order:
This is just a recommendation but having the imports at the top and exports at the bottom (for feature modules) is similar to the order we have in a normal ES6 module. Also having declarations close to exports makes it easy to spot which elements are public or private to the module.
Routing Module
The Angular team is now recommending of creating a separate modules for routes. So instead of having a file like this:
I have detected some inconsistencies between the code examples and the official style guide. Here are my findings and suggestions:
Filenames
ChildComponent
and the name of the file beingchild.ts
. In that case the filename should bechild.component.ts
.example.module.ts
we should follow the convention an name itapp.module.ts
.index.html
we should follow the convention and name itapp.component.ts
.Component
so instead of naming a component like:component-1.ts
Do:
first.component.ts
Imports
import { AppComponent, ChildComponent } from './';
do:Selectors
rio-
. So instead of havingapp-root
userio-app
.Module Decorator Properties
There's not an official recommendation about this, but every example that I see in angular.io declare the properties of the
NgModule
decorator in this order:This is just a recommendation but having the
imports
at the top andexports
at the bottom (for feature modules) is similar to the order we have in a normal ES6 module. Also havingdeclarations
close toexports
makes it easy to spot which elements are public or private to the module.Routing Module
The Angular team is now recommending of creating a separate modules for routes. So instead of having a file like this:
routes.ts
Do:
app-routing.module.ts
And then in your root module:
Others