Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
✳️ Implementing a Loading Skeleton in Angular

#angular #directive #skeleton #ui_element

Skeletons are placeholder elements that are displayed before the actual content is loaded on a webpage. A skeleton is usually a light gray box or circle that you see on websites like Medium, YouTube, etc. Skeletons convey a visual impression of the feature, which gives them an advantage over spinners.

βœ… Article Link: https://netbasal.com/implementing-a-loading-skeleton-in-angular-7490ffdecc1b

🎁 Code Link:
Step 1: https://gist.github.com/NetanelBasal/33f8ec9a106ee2367f3b9847fd3043cb#file-rect-ske-component-ts

Step 2: https://gist.github.com/NetanelBasal/82030b63d6ed0055c09a543483bd3470#file-skeleton-directive-ts

Step 3: https://gist.github.com/NetanelBasal/0f26e85d13d10a9e564541553094c12f#file-skeleton-demo-html
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ“„ Reusable Checkbox Input in Angular

#angular #ui_element #ControlValueAccessor

All we need to do is to use its selector inside our <form> HTML element with FormGroup:

<app-checkbox-input 
formControlName="fullName"
label="Check by Full Name"
></app-checkbox-input>


🚩 > Angular v16

βœ… Article link: https://blog.bitsrc.io/how-ive-created-reusable-checkbox-input-in-angular-16-5fd470f26104
πŸ“„ Deactivate Route Guards in Angular

#angular #guard #ui_element

The CanDeactivate route guard in Angular is responsible for determining if a route can be deactivated. It is commonly used when you want to check if the user is allowed to leave a particular component or route, perhaps due to unsaved changes or other dynamic conditions.


βœ… Article link
πŸ”₯2
πŸ“„ Simple Unsaved Data Changes Guard in Angular 17+

#angular #guard #ui_element

...when a user wants to navigate to other routes having pending data changes in the current page...


βœ… Article link
πŸ‘5
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„ Customizable Angular animations

#angular #animations #ui_element

...A component with customizable animations might look like this...


// collapse.ts

const closedStyle = style({
height: 0
});

const openStyle = style({
height: '*'
});

const timings = '{{duration}}ms linear';

const defOptions: AnimationOptions = {
params: {
duration: 300
}
};

export const collapse = trigger('collapse', [
transition(
':enter',
animation([closedStyle, animate(animateTimings, openStyle)]),
defaultOptions
),
transition(
':leave',
animation([openStyle, animate(animateTimings, closedStyle)]),
defaultOptions
),
]);


// bonus.component.ts

@Component({
animations: [collapse],
host: {
'[@collapse]': 'animationOptions',
},
})
export class BonusComponent implements OnInit {
@Input() public duration = 300;
public options!: IAnimationOptions<string>

public ngOnInit(): void {
this.options = {
value: '_',
params: {
duration: this.duration
},
};
}
}


βœ… Article link
πŸ‘3❀1πŸ”₯1
πŸ“„Managing the Sticky Navigation: Angular, Tailwind, and RxJS

#angular #rxjs #tailwind #navbar #ui_element

Explanation:
β€” `public readonly isSticky$ = fromEvent(window, 'scroll').pipe(...):` This defines the isSticky$ observable using RxJS operators. It listens for scroll events on the window, maps them to the vertical scroll position (window.scrollY), filters out consecutive duplicate values, and then maps the scroll position to a boolean value indicating whether the scroll position is greater than 24 (assuming 24 is a threshold value for determining when the navigation bar should become sticky).

β€” `distinctUntilChanged()`: This operator filters out consecutive duplicate values emitted by the observable.

β€” `map((scrollTop: number) => scrollTop > 24)`: This operator maps the scroll position (scrollTop) to a boolean value, indicating whether the user has scrolled past a certain threshold (24 in this case).

β€” `(isSticky$ | async) === true`: This condition checks if the value emitted by the isSticky$ is true or not. Which makes it convenient since you don’t have to unsubscribe the observable.

β€” `sticky top-0 z-10 shadow-lg opacity-95 bg-white`: These classes from TailWind will help enhance the sticky experience when the users scroll down.


βœ… Article link
πŸ“„ Infinite Scroll Component in Angular

#angular #rxjs #ui_element #infiniteScroll

βœ… Article link 🎁 Code Link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„ Angular Animations Tutorial: Route Transitions

#angular #ui_element #provideRouter #provideAnimations

export const routeTransition = trigger(
'routeTransition', [
transition('* => *', [
query(':enter', [
style({
opacity: 0,
scale: 0.9
}),
], { optional: true }),
query(':leave', [
animate('0.2s', style({
opacity: 0,
scale: 0.9
}))
], { optional: true }),
query(':enter', [
animate('0.2s', style({
opacity: 1,
scale: 1
}))
], { optional: true })
])
])


    <app-nav></app-nav>
<div
[@routeTransition]="data"
style="display: contents"
>
<router-outlet></router-outlet>
</div>


βœ… Article link

🎁 Code link
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1πŸ‘1
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„ AI writing assistant

#js #react #ui_element

....Imagine you’ve created an amazing AI writing assistant giving helpful suggestions for writing engaging stories....


βœ… Article link