Skip to content

Instantly share code, notes, and snippets.

@YuriFontella
Last active March 13, 2017 12:32
Show Gist options
  • Save YuriFontella/2d7580e43acad37cbf716d15b6bc3a11 to your computer and use it in GitHub Desktop.
Save YuriFontella/2d7580e43acad37cbf716d15b6bc3a11 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { FileUploader } from 'ng2-file-upload';
import { ProfileService } from './profile.service';
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.css']
})
export class ProfileComponent implements OnInit {
user: Object = [];
constructor(private route: ActivatedRoute, private profileService: ProfileService) { }
ngOnInit() {
this.profileService.user(this.route.snapshot.params['id']).subscribe(response => this.user = response.json());
this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
this.user['image'] = response;
};
}
public uploader: FileUploader = new FileUploader({url: 'http://127.0.0.1:3000/users/image', itemAlias: 'image' });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment