ng add @angular-eslint/schematics
npm i prettier prettier-eslint eslint-config-prettier eslint-plugin-prettier -D
Filename: .eslintrc.json
Inspired by dannyfritz/commit-message-emoji
See also gitmoji.
| Commit type | Emoji |
|---|---|
| Initial commit | 🎉 :tada: |
| Version tag | 🔖 :bookmark: |
| New feature | ✨ :sparkles: |
| Bugfix | 🐛 :bug: |
| export class AppComponent implements OnInit { | |
| public data$: Observable<any>; | |
| ngOnInit(): void { | |
| this.data$ = this.rest.get(`http://api-data.com`) | |
| } | |
| } |
| 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 { | |
| /** |
| 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( |
| 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 :) |