5 tips to boost your Angular skills
This summer me and Roman started a series of tweets with helpful tips and tricks about Angular. It was met well by the community so I decided to write an article follow-up. Here are 5 generalized advises I want to give to Angular developers across the globe. These advises are backed by some concrete examples pulled from our Twitter activity. They can help you improve your developer skills or give you some practical tricks at the very least.
1. Know how change detection works in Angular
There are many great articles going deep into change detection mechanism. Like this one. So let’s just recap the basics quickly and get to the tips.
Recap
Angular has two change detection modes: Default
and OnPush
. First one triggers change detection for every tick happened anywhere in the app. Second only marks view for checking if an event has happened in this view or if input data has changed.
Default
vs OnPush
There’s really no reason for you to use Default
. All you need to do is write your code the way framework expects it to and you won’t get into trouble with OnPush
. This means, you should never mutate your data. If your input arrays or objects change immutably, OnPush
would pick this up and refresh the view.