Skip to content

Instantly share code, notes, and snippets.

declare function bind<T>(component: React.ComponentType<T & InjectedProps>): React.ComponentType<T>;
declare class A<B> extends React.Component<PubProps<B> & InjectedProps> { }
const APrimeComponent = bind(A);
// type inferred to: React.ComponentType<PubProps<unknown>>
declare function AFunc<B>(props: PubProps<B> & InjectedProps): React.ReactElement;
const AFuncPrimeComponent = bind(AFunc);
// type inferred to: React.ComponentType<PubProps<unknown>>
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Post } from '../model';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import "rxjs/add/observable/combineLatest";
import "rxjs/add/observable/merge";
import "rxjs/add/operator/map";
import "rxjs/add/operator/switchMap";
@miloszpp
miloszpp / band-details.component.ts
Created October 10, 2017 20:01
Szkolenie Angular: ćwiczenie 7
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Band } from "../model";
import { ColorService } from "../color.service";
@Component({
selector: 'app-band-details',
templateUrl: './band-details.component.html',
styles: []
})
export class BandDetailsComponent implements OnInit {
@miloszpp
miloszpp / band-details.component.html
Last active October 9, 2017 21:58
Szkolenie Angular: ćwiczenie 6
<h1 [style.textTransform]="textTransform" [style.color]="color">
<button (click)="previous()">&lt;</button> Zespół: {{band.name}}
<button (click)="next()">&gt;</button>
</h1>
<div>
<label><input type="checkbox" [(ngModel)]="showBio" />Pokaż biografię</label>
<p *ngIf="showBio">{{band.bio}}</p>
</div>
<div>
Gatunki muzyczne:
@miloszpp
miloszpp / band-details-photo.component.ts
Created October 9, 2017 20:57
Szkolenie Angular: ćwiczenie 5
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-band-details-photo',
template: `
<label><input type="checkbox" [(ngModel)]="showPhoto" />Pokaż zdjęcie</label><br />
<img *ngIf="showPhoto" [src]="photoUrl" width="300" />
`,
styles: []
})
@miloszpp
miloszpp / app.component.html
Created October 8, 2017 16:09
Szkolenie Angular: ćwiczenie 4
<h1>Wybierz zespół</h1>
<select [(ngModel)]="band">
<option *ngFor="let band of bands" [ngValue]="band">{{band.name}}</option>
</select>
<div *ngIf="band">
<h1 [style.textTransform]="textTransform" [style.color]="color">Zespół: {{band.name}}</h1>
<div>
<label><input type="checkbox" [(ngModel)]="showBio" />Pokaż biografię</label>
<p *ngIf="showBio">{{band.bio}}</p>
@miloszpp
miloszpp / bands.json
Last active October 15, 2017 18:41
Szkolenie Angular: lista zespołów wraz z członkami
[
{
name: "Metallica",
bio: "Amerykański zespół heavymetalowy założony w Los Angeles w 1981 roku przez Jamesa Hetfielda i Larsa Ulricha.",
links: {
wikipediaUrl: "https://pl.wikipedia.org/wiki/Metallica",
photoUrl: "https://up-1.cdn-fullscreendirect.com/production/photos/7549/large/20161022_184841_7549_958066.jpeg"
},
genres: ["rock", "metal"],
members: ["James Hetfield", "Lars Urlich", "Kirk Hammett", "Robert Trujillo"]
@miloszpp
miloszpp / bands.json
Last active October 8, 2017 15:34
Szkolenie Angular: lista zespołów
[
{
name: "Metallica",
bio: "Amerykański zespół heavymetalowy założony w Los Angeles w 1981 roku przez Jamesa Hetfielda i Larsa Ulricha.",
links: {
wikipediaUrl: "https://pl.wikipedia.org/wiki/Metallica",
photoUrl: "https://up-1.cdn-fullscreendirect.com/production/photos/7549/large/20161022_184841_7549_958066.jpeg"
},
genres: ["rock", "metal"]
},
@miloszpp
miloszpp / app.component.ts
Created October 8, 2017 15:13
Szkolenie Angular: ćwiczenie 3
import { Component } from '@angular/core';
import { Band } from "./model";
@Component({
selector: 'app-root',
template: `
<h1 [style.textTransform]="textTransform" [style.color]="color">Zespół: {{band.name}}</h1>
<div>
<label><input type="checkbox" [(ngModel)]="showBio" />Pokaż biografię</label>
<p *ngIf="showBio">{{band.bio}}</p>
@miloszpp
miloszpp / app.component.ts
Last active October 8, 2017 14:10
Szkolenie Angular: ćwiczenie 2
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<h1 [style.textTransform]="textTransform" [style.color]="color">Zespół: {{name}}</h1>
<div>
<label><input type="checkbox" [(ngModel)]="showBio" />Pokaż biografię</label>
<p *ngIf="showBio">{{bio}}</p>
</div>