You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<br>[⭐ Interactive demo of this snippet](https://30.codelab.fun/accessing-enums-in-template) | [⬆ Back to top](#table-of-contents) | tags: [enums](https://30.codelab.fun/tags/enums)[templates](https://30.codelab.fun/tags/templates)
458
461
<br><br>
462
+
### Angular cheat sheet
463
+
Check out [Angular Cheat Sheet](https://angular.io/guide/cheatsheet) which contains lots of useful information condensed in one place.
464
+
465
+
There's also an [alternative version](https://malcoded.com/angular-cheat-sheet).
<br>[⭐ Interactive demo of this snippet](https://30.codelab.fun/angular-cheat-sheet) | [⬆ Back to top](#table-of-contents) | tags: [tip](https://30.codelab.fun/tags/tip)[cheat sheet](https://30.codelab.fun/tags/cheat-sheet)
472
+
<br><br>
459
473
### Default ViewEncapsulation value
460
474
If you're using `ViewEncapsulation` value which is different than default, it might be daunting to set the value manually for every component.
<br>[⭐ Interactive demo of this snippet](https://30.codelab.fun/default-viewencapsulation-value) | [⬆ Back to top](#table-of-contents) | tags: [configuration](https://30.codelab.fun/tags/configuration)[styling](https://30.codelab.fun/tags/styling)
476
490
<br><br>
491
+
### hammerjs-gestures
492
+
To act upon swipes, pans, and pinhces as well as the other mobile gestures, you can use `hammerjs` with `HostListener` decorator, or an event binding,
493
+
494
+
```bash
495
+
npm install hammerjs
496
+
```
497
+
498
+
```typescript
499
+
@HostListener('swiperight')
500
+
publicswiperight(): void {
501
+
// Run code when a user swipes to the right
502
+
}
503
+
```
504
+
505
+
<details>
506
+
<summary>Bonus</summary>
507
+
508
+
Here are samples on how to use all of the `hammerjs` event bindings, you can use these events with a `HostListener` as well:
<br>[⭐ Interactive demo of this snippet](https://30.codelab.fun/hammerjs-gestures) | [⬆ Back to top](#table-of-contents) | tags: [good-to-know](https://30.codelab.fun/tags/good-to-know)[tips](https://30.codelab.fun/tags/tips)[components](https://30.codelab.fun/tags/components)[gestures](https://30.codelab.fun/tags/gestures)
558
+
<br><br>
477
559
### Loader Component
478
560
You can create own helper component and use it instead of `*ngIf`.
<br>[⭐ Interactive demo of this snippet](https://30.codelab.fun/renaming-inputs-and-outputs) | [⬆ Back to top](#table-of-contents) | tags: [components](https://30.codelab.fun/tags/components)[templates](https://30.codelab.fun/tags/templates)
595
677
<br><br>
678
+
### Safe Navigation Operator
679
+
The [Safe Navigation Operator](https://angular.io/guide/template-syntax#the-safe-navigation-operator----and-null-property-paths) helps with preventing null-reference exceptions in component template expressions. It returns object property value if it exists or null otherwise.
680
+
681
+
```html
682
+
<p> I will work even if student is null or undefined: {{student?.name}} </p>
<br>[⭐ Interactive demo of this snippet](https://30.codelab.fun/safe-navigation-operator) | [⬆ Back to top](#table-of-contents) | tags: [object property handling](https://30.codelab.fun/tags/object-property-handling)[tips](https://30.codelab.fun/tags/tips)[good to know](https://30.codelab.fun/tags/good-to-know)
701
+
<br><br>
596
702
### trackBy in for loops
597
703
To avoid the expensive operations, we can help Angular to track which items added or removed i.e. customize the default tracking algorithm by providing a trackBy option to NgForOf.
Check out [Angular Cheat Sheet](https://angular.io/guide/cheatsheet) or ([alternative version](https://malcoded.com/angular-cheat-sheet)) containing lots of useful information condensed in one place.
18
+
19
+
Also [Angular Checklist](https://angular-checklist.io) contains is curated list of common mistakes made when developing Angular applications.
0 commit comments