This file contains hidden or 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
/** | |
* @param {number} a | |
* @param {number} b | |
* @return {number} | |
*/ | |
function sum(a, b) { | |
return a+b; | |
} |
This file contains hidden or 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 { faBalanceScale } from '@fortawesome/pro-solid-svg-icons'; | |
import { faBan } from '@fortawesome/pro-regular-svg-icons'; | |
export class IconsModule { | |
constructor(library: FaIconLibrary) { | |
library.addIcons( | |
faBalanceScale, | |
faBan, | |
//... and the rest of icons) | |
} |
This file contains hidden or 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
resolveProduct(code: string): Observable<any> { | |
if (this.cache[code]) { | |
console.log('Returning cached value!') | |
return this.cache[code]; | |
} | |
console.log('Do the request again') | |
this.cache[code] = this.http.get(this.URL+code+'.json').pipe( | |
shareReplay(1), | |
catchError(err => { |
This file contains hidden or 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
<my-product code="7613034626844"></my-product> | |
<my-product code="7613034626844"></my-product> | |
<my-product code="7613034626844"></my-product> |
This file contains hidden or 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
@Component({ | |
selector: 'my-app', | |
template: `<my-product code="7613034626844"></my-product> | |
<my-product code="7613034626844"></my-product> | |
<my-product code="7613034626844"></my-product>`, | |
}) | |
export class AppComponent { | |
} |
This file contains hidden or 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
@Component({ | |
selector: 'my-product', | |
template: ` | |
<pre *ngIf="code"> | |
{{(result$|async)|json}} | |
</pre> | |
`, | |
}) | |
export class ProductComponent { | |
@Input() |
This file contains hidden or 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
npm run i18n && ng build --base-href / --aot --prod --stats-json |
This file contains hidden or 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 class IconsModule { | |
constructor(library: FaIconLibrary) { | |
library.addIconPacks(far); | |
library.addIconPacks(fas); | |
library.addIconPacks(fasPro); | |
} | |
} |
This file contains hidden or 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
<fa-icon [icon]="['fas', 'coffee']" size="xs"></fa-icon> |
This file contains hidden or 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 class ProductService { | |
private readonly URL = 'https://world.openfoodfacts.org/api/v0/product/'; | |
constructor(private http: HttpClient) { | |
} | |
cache = {}; | |