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 { Painter } from './painter'; | |
export var PAINTERS: Painter[] = [ | |
{ | |
id: 1, | |
name: 'Michelangelo', | |
style: 'Renaissance', | |
examples: ['David', 'Sistine Chapel', 'The Last Judgement'] | |
}, | |
{ |
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 interface Painter { | |
id: number; | |
name: string; | |
style: string; | |
examples: string[]; | |
} |
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 } from '@angular/core'; | |
import { Painter } from './painter'; | |
@Component({ | |
inputs: ['painter'], | |
selector: 'my-painter-detail', | |
template: ` | |
<div *ngIf="painter"> | |
<h2>{{painter.name}}</h2> |
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'; | |
import { Painter } from './painter'; | |
import { PAINTERS } from './painters.mock'; | |
@Injectable() | |
export class PainterService { | |
getPainters(): Promise<Painter[]> { | |
return Promise.resolve(PAINTERS); |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Angular 2 Famous Painters</title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="styles/app.css"> |
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
{ | |
"name": "angular2-famous-painters", | |
"author": "noob", | |
"version": "1.0.0", | |
"scripts": { | |
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", | |
"lite": "lite-server", | |
"postinstall": "typings install", | |
"tsc": "tsc", | |
"tsc:w": "tsc -w", |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"removeComments": false, | |
"noImplicitAny": false |
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
(function() { | |
'use strict'; | |
/** | |
* Formats a string and returns a valid IBAN account string | |
* @param {string} input example: 'ES0123456789012345678901' | |
* @return {string} output example: 'ES01 2345 6789 0123 4567 8901' | |
* @example <caption>{{'ES0123456789012345678901' | IBAN}}</caption> | |
*/ | |
angular.module('app').filter('IBAN', () => iban => iban ? iban.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim() : ''); |
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
select replace(xmlquery('$array/array/id[last()]/text()' passing xmltype('<array><id>$1</id><id>$2</id><id>$3</id></array>') as "array" returning content), '$', '') from dual; |
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
// reduce() awesomeness | |
const a = [1, 2, 3, 4, 5, 5, 3] | |
const b = [{ key: 1, value: 'a' }, { key: 2, value: 'b' }] | |
const c = [Promise.resolve(), Promise.resolve(), Promise.resolve()] | |
const d = ['a', 'a', 'a', 'a', 'a'] | |
// Max | |
a.reduce((x, y) => x > y ? x : y) // > 5 | |
// Min |