@ngodings/ngx-ip
Version:
Simple get your ip in Angular
63 lines (57 loc) • 2.68 kB
JavaScript
import * as i0 from '@angular/core';
import { NgModule, Injectable } from '@angular/core';
import { CommonModule } from '@angular/common';
import * as i1 from '@angular/common/http';
import { HttpClientModule } from '@angular/common/http';
import { __awaiter } from 'tslib';
class NgxIPModule {
}
NgxIPModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NgxIPModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
NgxIPModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: NgxIPModule, imports: [CommonModule, HttpClientModule] });
NgxIPModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NgxIPModule, imports: [CommonModule, HttpClientModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: NgxIPModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, HttpClientModule],
declarations: [],
exports: []
}]
}] });
class IPService {
constructor(http) {
this.http = http;
this.ip = '';
this.ipURL = 'https://api.ipify.org?format=json';
}
getIP() {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
if (this.ip) {
resolve(this.ip);
}
this.http.get(this.ipURL)
.subscribe((data) => {
this.ip = data === null || data === void 0 ? void 0 : data.ip;
resolve(this.ip);
});
}));
});
}
}
IPService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: IPService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
IPService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: IPService, providedIn: 'root' });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: IPService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
/*
* Public API Surface of ngx-timezone
*/
/**
* Generated bundle index. Do not edit.
*/
export { IPService, NgxIPModule };
//# sourceMappingURL=ngodings-ngx-ip.mjs.map
//# sourceMappingURL=ngodings-ngx-ip.mjs.map