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
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;
});
@rajaramtt
rajaramtt / Sass.md
Last active May 29, 2021 09:10
Sass (which stands for Syntactically Awesome Style Sheets) is an extension to CSS

Sass (which stands for Syntactically Awesome Style Sheets) is an extension to CSS.

sass is superset of css Sass is syntatic sugar of css It helps in writing CSS quickly.

SASS supports two syntaxes namely SCSS and Indented syntax

  • The SCSS - is an extension of CSS syntax. files use the extension .scss.
@rajaramtt
rajaramtt / difference between the HashLocationStrategy and PathLocationStrategy.md
Created August 31, 2019 19:56
Know the difference between the HashLocationStrategy and PathLocationStrategy.

To enable HashLocationStrategy in an Angular application we pass {useHash: true} when we are providing our routes with RouterModule, like so:

TypeScript RouterModule.forRoot(routes, {useHash: true})

http://somedomain.com/page#routing-strategies Taking a look at the app we’ve built so far, if running locally the URLs look something like:

localhost:4040/#/search localhost:4040/#/artist/1234/tracks

@rajaramtt
rajaramtt / CUSTOM_ELEMENTS_SCHEMA vs NO_ERRORS_SCHEMA in Angular8.md
Last active August 11, 2020 15:33
CUSTOM_ELEMENTS_SCHEMA vs NO_ERRORS_SCHEMA in Angular8

Including the CUSTOM_ELEMENTS_SCHEMA in the module allows the use of the web components in the HTML markup without the compiler producing errors

  • Defines a schema that allows an NgModule to contain the following:
    • Non-Angular elements named with dash case (-).
    • Element properties named with dash case (-).
  • Dash case is the naming convention for custom elements.
@rajaramtt
rajaramtt / media-query.css
Created August 9, 2019 11:07 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@rajaramtt
rajaramtt / object into query string parameters in JavaScript.js
Created June 28, 2019 14:03
object into query string parameters in JavaScript
var params = {
a: 1,
b: 2,
c: 3
};
var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
// or
var queryString = Object.keys(params).map(function(key) {
@rajaramtt
rajaramtt / angular-configuring.md
Created May 29, 2019 07:16
Configuring application environments

environments ├── environment.staging.ts

angular.json

"configurations": {

"staging": { "fileReplacements": [

@rajaramtt
rajaramtt / angular.json
Last active September 10, 2019 11:58
Stage environment setup in angular
"configurations": {
"production": { ... },
"staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
]
}