Skip to content

Instantly share code, notes, and snippets.

View Mustafa-Omran's full-sized avatar
💭
I may be slow to respond.

Mustafa Omran Mustafa-Omran

💭
I may be slow to respond.
  • Egypt
View GitHub Profile
@Mustafa-Omran
Mustafa-Omran / angular-custom-directive.ts
Last active February 21, 2022 08:55
Angular -custom directive for dynamic direction (rtl or ltr)
@Directive({
selector: '[setDirection]'
})
export class SetDirDirective {
/**
*
* @param el
* @param languageService
* @param locale
*/
@Mustafa-Omran
Mustafa-Omran / angular-custom-directive-click-outside-element.ts
Created February 21, 2022 09:00
Angular - Custom directive when clicking outside specific element
@Directive({
selector: '[clickOutsideElement]'
})
export class ClickOutsideDirective {
@Output() clickOutside = new EventEmitter<void>();
constructor(private elementRef: ElementRef) { }
@HostListener('document:click', ['$event.target'])
onClickOutsideElement(target) {
@Mustafa-Omran
Mustafa-Omran / angular-auth-guard.ts
Created February 21, 2022 09:03
Angular- Auth Guard
@Injectable({
providedIn: 'root'
})
export class AuthGuard implements CanActivate {
constructor(
private readonly router: Router) {
}
@Mustafa-Omran
Mustafa-Omran / environment.ts
Last active February 21, 2022 09:25
Angular - Set Http Client
const settings: Settings = {
backendUrl: 'http://...',
};
@Mustafa-Omran
Mustafa-Omran / Angular - OSM Search Service (nominatim).ts
Last active February 21, 2022 09:29
OpenStreetMap - Search service (nominatim)
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class SearchService {
private static readonly endpoint = 'https://nominatim.openstreetmap.org/search?format=json';
@Mustafa-Omran
Mustafa-Omran / angular-reactive-form-array.html
Last active January 20, 2024 07:22
angular - Reactive Forms Array (dynamic rows)
<form [formGroup]="form">
<div formArrayName="students" *ngFor="let student of students.controls; let index = index; let last = last">
<mat-card [formGroupName]="index">
<mat-card-title>
<p>student #{{index + 1}}</p>
<mat-icon (click)="removeStudent()" class="remove">delete</mat-icon>
</mat-card-title>
<mat-card-content>
<mat-form-field>
@Mustafa-Omran
Mustafa-Omran / filter.html
Created February 21, 2022 10:03
Angular - Filter Tables Or any List using Shared Custom Pipe Filter
<mat-option *ngFor="let value of list | filter:searchKeywords" [value]="value.id" matTooltip="{{value.name}}">
{{value.name}}
</mat-option>
@Mustafa-Omran
Mustafa-Omran / export-to-pdf.html
Last active June 27, 2024 15:22
Angular - Export Multiple Pages with PDF format - Using jsPDF && html2canvas packages
<div id="print-section">
<!-- template here -->
</div>
@Mustafa-Omran
Mustafa-Omran / demo.html
Last active February 23, 2022 15:11
Angular - Custom directive to accept only positive numbers within inputs
<!-- keep it as text to hide arrow up and down -->
<!-- user can add negative numbers if type number -->
<input type="text" positiveNumbers>
@Mustafa-Omran
Mustafa-Omran / autocomplete-off.html
Created February 23, 2022 12:36
HTML - Disable autocomplete suggestions
<input type="text" autocomplete="off" autocomplete="chrome-off">