node
withnpm
installed@angular/cli
installed or runnpm i -g @angular/cli@latest
vscode
,webstorm
or other editor installed- feeling adventurous :)
-
We'll be using https://jsonplaceholder.typicode.com/ as a data source
- use
ng generate
command from@angular/cli
to generate anything quickly
- create new angular app, for how it's done visit https://cli.angular.io/
- try to experiment with various options of
new
command - app should be generated and all dependencies installed, if not - switch to folder and run
npm i
-
Overall look and feel:
- there is home page with link to
users
page - page/route structure should look like this:
/users
- lists all users available from api/user/:userId
lists user info andalbums
at the top andposts
below/user/:userId/albums
lists samealbums
asuser/:userId
page/user/:userId/albums/:albumId/photos
lists photos byalbumId
/user/:userId/posts
list of posts by that user & contains linkload replies
to load replies by thatpostId
- should contain text field and a button to add
posts
and/orcomment
, handle response and append thatpost
and/orcomment
- should contain text field and a button to add
- there is home page with link to
-
Feature usage:
- Must include following:
ngIf
to show/hide add comment componentngFor
with optimisations (as you load replies there might be performance issues like freezing)components
that are reused:albums
component on/users/:userId
route andalbums
on/albums
routeDirective
to highlight odd/evenpost
Resolve
that loads data when route is activatedGuard
to check whetheralbum
orpost
belongs to that userHttpClient
to load dataHttpInterceptor
to handle404
error@Injectable
service to useHttpClient
insideLazy
modules for at least one routerouterLink
for navigationrxjs
operators likefilter
,map
etc.FormGroup
&FormControl
to add commentValidators
and view validation messages
- Must include following:
-
Well-defined structure:
- each module in separate folder
- each module folder should contain separate folders for
components
,services
,directives
,child modules
if any etc . - there should be separate module for routing, and module that contains all declarations/providers that also imports routing module
- every feature (like
posts
,photos
,albums
) should be contained in separate feature module with it's own routing - every feature module should be lazy-loaded from main
app.module
's routing module - components should follow
SOLID
-like principle - be as granular as possible