Skip to content

Instantly share code, notes, and snippets.

View rajaramtt's full-sized avatar
🤘
Learning and Sharing

Raja Ram T rajaramtt

🤘
Learning and Sharing
  • Hyderabad, India
View GitHub Profile
@rajaramtt
rajaramtt / angular forms.ts
Created May 17, 2020 11:44
angular forms
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
})
export class AppComponent {
form = this.formBuilder.group({
firstName: [''],
lastName: [''],
age: [''],
});
Property
<img [src]="heroImageUrl">
<app-hero-detail [hero]="currentHero"></app-hero-detail>
<div [ngClass]="{'special': isSpecial}"></div>
Event
<button (click)="onSave()">Save</button>
@rajaramtt
rajaramtt / map.ts
Last active September 14, 2020 19:54
/*
{
"goodPackage": {
"upsellList": [
{
"productCode": "product1"
}
]
@rajaramtt
rajaramtt / Type Script .md
Last active January 5, 2020 18:55
Type Script

Annotations: TypeScript is statically typed and, therefore, all checks are performed at compile time. As mentioned before Types are annotated using :TypeAnnotation syntax.

Primitive Types

let isDone: boolean = false;
import { Directive, Input, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: '[appNumbersOnly]'
})
export class NumbersOnlyDirective {
@Input() fieldMaxLength: number;
constructor(private _el: ElementRef) { }
@HostListener('keypress', ['$event']) onkeypress(event) {
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: '[appFocusfirstInvalidfield]'
})
export class FocusfirstInvalidfieldDirective {
constructor(private el: ElementRef) { }
@HostListener('submit', ['$event'])
import { Directive, HostListener } from '@angular/core';
@Directive({
selector: '[appBlockCopyPaste]'
})
export class BlockCopyPasteDirective {
constructor() { }
@HostListener('paste', ['$event']) blockPaste(e: KeyboardEvent) {
e.preventDefault();
@rajaramtt
rajaramtt / angular imp notes.md
Last active September 12, 2019 18:20
angular imp notes

Angular Preloading Strategy

Preloading in Angular means loading the Lazy loaded Modules in the background asynchronously, while user is interacting with the app. This will help boost up the loading time of the app

const app_routes: Routes = [
public onlineOffline: boolean = navigator.onLine;
constructor(.......)
................
................
ngOnInit() {
window.addEventListener('online', () => {
this.onlineOffline = true;
});