Skip to content

Instantly share code, notes, and snippets.

import { Component, PLATFORM_ID , Inject} from '@angular/core';
import { isPlatformServer } from '@angular/common'
import { TransferState , makeStateKey} from '@angular/platform-browser';
import { HttpClient } from '@angular/common/http'
interface CounterState {
count: number;
}
const COUNTER_KEY = makeStateKey<CounterState>('my-counter');
//usage
const MY_STORE_TOKEN = new InjectionToken('MY_STORE_TOKEN');
@NgModule({
providers: [
//on the ServerModule you want to provide
//ServerStateTransferModule
BrowserStateTransferModule,
//helper function which will provide the store accosiated with this token
@Toxicable
Toxicable / file-upload.component.ts
Created October 23, 2016 07:18
How to upload files in angular 2
/**
* Created by Fabian on 19/10/2016.
*/
import { Component, ElementRef, Input } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'file-upload',
template: '<input type="file" [attr.multiple]="multiple ? true : null" (change)="upload()" >'
})
export class FileUploadComponent {