Skip to content

Instantly share code, notes, and snippets.

class ImageSnippet {
constructor(public src: string, public file: File) {}
}
@Component({
selector: 'bwm-image-upload',
templateUrl: 'image-upload.component.html',
styleUrls: ['image-upload.component.scss']
})
class ImageSnippet {
constructor(public src: string, public file: File) {}
}
@Component({
selector: 'bwm-image-upload',
templateUrl: 'image-upload.component.html',
styleUrls: ['image-upload.component.scss']
})
export class ImageUploadComponent {
export class ImageService {
constructor(private http: Http) {}
public uploadImage(image: File): Observable<Response> {
const formData = new FormData();
formData.append('image', image);
class ImageSnippet {
pending: boolean = false;
status: string = 'init';
constructor(public src: string, public file: File) {}
}
@Component({
selector: 'bwm-image-upload',
templateUrl: 'image-upload.component.html',
<label class="image-upload-container btn btn-bwm">
<span>Select Image</span>
<input #imageInput
type="file"
accept="image/*"
(change)="processFile(imageInput)">
</label>
<label class="image-upload-container btn btn-bwm">
<span>Select Image</span>
<input #imageInput
type="file"
accept="image/*"
(change)="processFile(imageInput)">
</label>
input {
display: none;
}
.image-upload-container {
cursor: pointer;
}
.img-preview-container {
import { NgModule } from '@angular/core';
import { AgmCoreModule } from '@agm/core';
import { CommonModule } from '@angular/common';
import { MapComponent } from './map.component';
import { MapService } from './map.service';
@NgModule({
declarations: [
MapComponent
private geocodeLocation(location: string): Observable<any> {
if (!this.geoCoder) this.geoCoder = new (<any>window).google.maps.Geocoder();
return new Observable((observer) => {
this.geoCoder.geocode({address: location}, (result, status) => {
if (status === 'OK') {
const geometry = result[0].geometry.location;
const coordinates = {lat: geometry.lat(), lng: geometry.lng()};
<agm-map
(mapReady)="mapReadyHandler()"
[latitude]="lat"
[longitude]="lng"
[zoom]="13">
<agm-circle *ngIf="lat && lng"
[latitude]="lat"
[longitude]="lng"
[radius]="800"
[fillColor]="'#F44336'"