This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input, AfterViewInit, Output, EventEmitter, ViewChild, ElementRef, ChangeDetectorRef } from '@angular/core'; | |
import olMap from 'ol/Map'; | |
import View from 'ol/View'; | |
import TileLayer from 'ol/layer/Tile'; | |
import XYZ from 'ol/source/XYZ'; | |
import WebGLPointsLayer from 'ol/layer/WebGLPoints'; | |
import { LiteralStyle, SymbolType } from 'ol/style/LiteralStyle'; | |
import { Feature } from 'ol'; | |
import { fromLonLat } from 'ol/proj'; | |
import Point from 'ol/geom/Point'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const flatMap = (fn, arr: any[]): any[] => [].concat.apply([], arr.map(fn)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({name: 'groupBy'}) | |
export class GroupByPipe implements PipeTransform { | |
transform(value: Array<any>, objKey: string): Array<any> { | |
// prevents the application from breaking if the array of objects doesn't exist yet | |
if (!value) { | |
return null; | |
} | |
const groupedCollection = value.reduce((previous, current) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class CSVService { | |
async toJSON(str: string, delimiter: string) { | |
// `\\${delimiter}(?=\S)\\` | |
const regExp = new RegExp(delimiter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// créer une class qui extend HTMLElement | |
class UserDetailsCard extends HTMLElement { | |
constructor() { | |
super(); | |
// Ajouter un click listener sur notre component | |
this.addEventListener('click', e => { | |
this.toggleDetails(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const userData = async (id = 1) => { | |
const user = await fetch(`https://reqres.in/api/users/${id}`) | |
.then(res => res.json()) | |
.then(res => (res && res.data) ? res.data : null); | |
console.log(user); | |
return user; | |
} | |
userData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const userData = (id = 1) => { | |
const user = fetch(`https://reqres.in/api/users/${id}`) | |
.then(res => res.json()) | |
.then(res => (res && res.data) ? res.data : null); | |
console.log(user); | |
return user; | |
} | |
userData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, Input, HostListener, ElementRef } from '@angular/core'; | |
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; | |
@Component({ | |
selector: 'app-file-upload', | |
template: ` | |
<div> | |
<span>Choose file</span> | |
<span>{{file ? file.name : 'or drag and drop file here' }}</span> | |
<input class="file-input" type="file"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, Input, HostListener, ElementRef } from '@angular/core'; | |
@Component({ | |
selector: 'app-file-upload', | |
template: ` | |
<div> | |
<span>Choose file</span> | |
<span>{{file ? file.name : 'or drag and drop file here' }}</span> | |
<input class="file-input" type="file"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { Validators, FormGroup, FormControl, FormArray } from '@angular/forms'; | |
@Component({ | |
selector: 'my-component', | |
template: ` | |
<form [formGroup]="form"> | |
<ul formArrayName="items"> | |
<li [formGroupName]="i" *ngFor="let itemCtrl of form.get('items')?.controls; let i = index" > | |
<input formControlName="title" name="title" type="text" /> <button (click)="removeItem(i)">X</button> |