diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0ed4d48..8b68d9a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,6 +8,7 @@ import { ListComponent } from './list/list.component'; import { DetailComponent } from './detail/detail.component'; import {FormsModule} from "@angular/forms"; import {HttpClientModule} from "@angular/common/http"; +import { SafePipe } from './pipes/safe.pipe'; @NgModule({ declarations: [ @@ -19,8 +20,7 @@ import {HttpClientModule} from "@angular/common/http"; imports: [ BrowserModule, AppRoutingModule, - FormsModule, - HttpClientModule, + FormsModule ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/detail/detail.component.html b/src/app/detail/detail.component.html index be1e21f..7840198 100644 --- a/src/app/detail/detail.component.html +++ b/src/app/detail/detail.component.html @@ -3,6 +3,15 @@
{{test.description}}
Distanza: {{distance}}
diff --git a/src/app/detail/detail.component.ts b/src/app/detail/detail.component.ts index 484fe87..e57e9f1 100755 --- a/src/app/detail/detail.component.ts +++ b/src/app/detail/detail.component.ts @@ -25,10 +25,14 @@ export class DetailComponent implements OnInit { test = { name: 'SPAI', - cordinates: "46.15187077044123, 8.799829438699243", + cordinates: '46.15187077044123,8.799829438699243', + lat: 46.15187077044123, + lng: 8.799829438699243, description: "Lorem ipsum" } + embed = `https://www.google.com/maps/embed/v1/place?key=AIzaSyBJL4FWmG032BG6KXxTb4faxpO_ccyaP3o&q=${this.test.lat},${this.test.lng}` + cord = { lat: 0, lng: 0 @@ -39,6 +43,7 @@ export class DetailComponent implements OnInit { displayedDistance = 0; getLocation() { + console.log(this.embed) console.log("get location"); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition((position) => { diff --git a/src/app/pipes/safe.pipe.spec.ts b/src/app/pipes/safe.pipe.spec.ts new file mode 100644 index 0000000..49ee0ad --- /dev/null +++ b/src/app/pipes/safe.pipe.spec.ts @@ -0,0 +1,8 @@ +import { SafePipe } from './safe.pipe'; + +describe('SafePipe', () => { + it('create an instance', () => { + const pipe = new SafePipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/app/pipes/safe.pipe.ts b/src/app/pipes/safe.pipe.ts new file mode 100644 index 0000000..3225fae --- /dev/null +++ b/src/app/pipes/safe.pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import {DomSanitizer} from "@angular/platform-browser"; + +@Pipe({ + name: 'safe' +}) +export class SafePipe implements PipeTransform { + constructor(private domSanitizer: DomSanitizer) {} + transform(url:string) { + return this.domSanitizer.bypassSecurityTrustResourceUrl(url); + } + +}