Skip to content

Instantly share code, notes, and snippets.

View Leoneider's full-sized avatar
🏠
Working from home

DevOps42 Leoneider

🏠
Working from home
View GitHub Profile
@Leoneider
Leoneider / config.md
Created January 10, 2023 03:45 — forked from bezael/config.md

Install Angular ESLint

ng add @angular-eslint/schematics

Install Prettier and Prettier-ESLint dependencies

npm i prettier prettier-eslint eslint-config-prettier eslint-plugin-prettier -D

ESLint configuration

Filename: .eslintrc.json

@Leoneider
Leoneider / GitCommitEmoji.md
Created December 29, 2022 22:18 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
export class AppComponent implements OnInit {
public data$: Observable<any>;
ngOnInit(): void {
this.data$ = this.rest.get(`http://api-data.com`)
}
}
@Leoneider
Leoneider / example_1.ts
Created March 24, 2021 13:29 — forked from leifermendez/example_1.ts
Subscribe & UnSubscribe
import { Component, OnDestroy, OnInit, VERSION } from "@angular/core";
import { SharedService } from "./shared.service";
@Component({
selector: "my-app",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent implements OnInit, OnDestroy {
/**
@Leoneider
Leoneider / example_2.ts
Created March 24, 2021 13:29 — forked from leifermendez/example_2.ts
Lazy Load
const routes: Routes = [
{
path: '',
component: HomeComponent,
children: [
{
path: 'auth',
loadChildren: './modules/auth/auth.module#AuthModule'
},
{
import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const token = localStorage.getItem('auth_token');
if (!token) {
return next.handle(req);
}
<ul>
<li *ngFor="let item of data$ | async">
{{item}}
</li>
</ul>
search = (q: string, exportData = false, limit = 0) => {
this.results$.total = 0;
if (q.length > 2) {
this.results$.q = q;
this.loading = true;
const url = (exportData) ? `overview/search?q=${q}&export=xlsx&limit=${limit}` : `overview/search?q=${q}`;
this.results$.docs = this.rest.get(url,
true, {ignoreLoadingBar: ''})
.pipe(
@Leoneider
Leoneider / main.ts
Created March 24, 2021 13:27 — forked from leifermendez/main.ts
Main.ts Angular
if (environment.production) {
enableProdMode();
if (window) {
window.console.log = window.console.warn = window.console.info = function () {
// Don't log anything.
};
const w = window as any;
window.console.error = function ($event, more) {
console.log(' 😠 ERROR', more)
// Se debe obtener la fecha en formato YYYY/MM/DD muy importante usar '/' para separar
const start = moment.utc('2020-07-13T14:04:45.098Z').format('YYYY/MM/DD') // 2020/07/13
// Luego se debe volver a parsear indicando los '/'
moment(start, 'YYYY/MM/DD').toDate() //2020/07/13 :)