0
私はAngular2のタイプコードで簡単に使用できるユーザーの場所(少なくとも地理的地域)を探しています。Angular2でユーザーの現在の地域を読み取る方法は?
私はAngular2のタイプコードで簡単に使用できるユーザーの場所(少なくとも地理的地域)を探しています。Angular2でユーザーの現在の地域を読み取る方法は?
import { Injectable} from '@angular/core';
import { Observable } from 'rxjs/Observable';
import {Http} from '@angular/http';
import 'rxjs/Rx';
@Injectable()
export class CurrentLocationService {
constructor(private _http: Http) {}
getCurrentLocation(): Observable<any> {
return this._http.get('http://ipinfo.io/json?callback=JSON_CALLBACK')
.map(response => response.json())
.catch(error => {
console.log(error);
return Observable.throw(error.json());
});
}
}
JSで行う方法を確認しましたか?それはAngular ;-)と同じです –