From be568dc118ce803d34ee288e4ef334dc60a1859d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=20Ku=CC=88ng?= Date: Tue, 31 Jan 2023 15:54:13 +0100 Subject: [PATCH] get location home component --- src/app/detail/detail.component.html | 8 +++++++- src/app/home/home.component.html | 1 + src/app/home/home.component.ts | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/detail/detail.component.html b/src/app/detail/detail.component.html index fd9463a..9340443 100644 --- a/src/app/detail/detail.component.html +++ b/src/app/detail/detail.component.html @@ -1 +1,7 @@ -

detail works!

+ + diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index c0cb16a..03e0e23 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -1,3 +1,4 @@
+ diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 120d63d..e78472b 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -6,7 +6,13 @@ import {Component, OnInit} from '@angular/core'; styleUrls: ['./home.component.css'] }) export class HomeComponent implements OnInit { + latitude: number | undefined; + longitude: number | undefined; ngOnInit(): void { + navigator.geolocation.getCurrentPosition(position => { + this.latitude = position.coords.latitude; + this.longitude = position.coords.longitude; + }) } }