π Make TrackBy Easy to Use!
#angular #directive #ngFor #trackBy
β Article link: https://medium.com/ngconf/make-trackby-easy-to-use-a3dd5f1f733b
#angular #directive #ngFor #trackBy
β Article link: https://medium.com/ngconf/make-trackby-easy-to-use-a3dd5f1f733b
ifHasPermission Structural Directive in Angular#angular #directive
β Article link:
https://medium.com/@eugeniyoz/structural-directives-in-angular-61fe522f3427
π Creating a Custom Directive for Minimum Character Length in Angular
#angular #directive
β Article link: https://medium.com/@ayushgrwl365/angular-directives-enhancing-user-interfaces-with-ease-bb99d74e69cd
#angular #directive
β Article link: https://medium.com/@ayushgrwl365/angular-directives-enhancing-user-interfaces-with-ease-bb99d74e69cd
π Angular βletβ Directive
#angular #directive #ngTemplate
β Article link: https://javascript.plainenglish.io/angular-show-loading-spinner-for-observables-30f1bc96e19e
#angular #directive #ngTemplate
β Article link: https://javascript.plainenglish.io/angular-show-loading-spinner-for-observables-30f1bc96e19e
This media is not supported in your browser
VIEW IN TELEGRAM
π Resizable Columns in Angular Table
#angular #directive #ui_element
β Article link: https://levelup.gitconnected.com/how-to-create-resizable-columns-in-angular-scrollable-table-a-step-by-step-guide-5b8f766c1f60
π Code link: https://stackblitz.com/edit/angular-6x5egd?file=src%2Fapp%2Fdirectives%2Fcolumn-resize.directive.ts
#angular #directive #ui_element
β Article link: https://levelup.gitconnected.com/how-to-create-resizable-columns-in-angular-scrollable-table-a-step-by-step-guide-5b8f766c1f60
Please open Telegram to view this post
VIEW IN TELEGRAM
π1π₯1
π Angular Custom Directives: Custom Validation Directive
#angular #directive
#angular #directive
A custom validation directive in Angular allows you to create your own custom validation logic for form controls. In this example, weβll create a custom directive to validate that a password contains both letters and numbers. If the password doesnβt meet this criteria, weβll mark the form control as invalid and display an error message. Hereβs how you can create this custom validation directive
<input
type="password"
name="password"
[(ngModel)]="user.password"
#password="ngModel"
appPasswordValidator="[A-Za-z]+[0-9]+"
required
/>
<div *ngIf="
password.invalid
&& (password.dirty || password.touched)
">
<div *ngIf="password | hasError :'required'">
Password is required.
</div>
<div *ngIf="password | hasError :'passwordPattern'">
Password must contain letters and numbers.
</div>
</div>
π Angular Custom Directives: Autofocus Directive
#angular #directive
#angular #directive
In this example, we apply the appAutofocus directive to an input element. When the page loads, this input field will automatically receive focus, making it convenient for the user to start typing immediately.
<input
type="text"
placeholder="Auto-focused input"
appAutofocus
/>
import { Directive, ElementRef, AfterViewInit } from '@angular/core';
@Directive({
selector: '[appAutofocus]'
})
export class AutofocusDirective implements AfterViewInit {
constructor(private el: ElementRef) {}
ngAfterViewInit() {
this.el.nativeElement.focus();
}
}β€3
π Angular Custom Directives: Lazy Load Images Directive
#angular #directive
#angular #directive
Creating a custom directive in Angular for lazy-loading images can help improve the performance and user experience of your website by loading images only when they are visible on the screen. In this example, weβll create a custom directive named appLazyLoad to implement lazy loading for images.
<img
src="placeholder.jpg"
data-src="lazy-image.jpg"
alt="Lazy-loaded image"
appLazyLoad
/>
π2β€1
π Angular Custom Directives: Drag-and-Drop Directive
#angular #directive
#angular #directive
Creating a custom directive in Angular for drag-and-drop functionality can enhance the user experience by allowing users to interact with elements on your page. In this example, weβll create a custom directive named appDraggable to enable drag-and-drop functionality for elements.
<div appDraggable>
Drag me around!
</div>
β€3
π Angular Custom Directives: Ellipsis Directive
#angular #directive
#angular #directive
Creating a custom directive in Angular to add ellipsis to text that overflows its container can help improve the readability and aesthetics of your user interface. In this example, weβll create a custom directive named `appEllipsis` to add an ellipsis to text that exceeds its container's width.
<div appEllipsis>
This is a long text that will be truncated with an ellipsis if it overflows its container.
</div>