-
-
Save lx4r/07b846b337ba45cbd5a9dd2eaca291bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable, Component} from 'angular2/core'; | |
import {SqlStorage, Storage} from 'ionic-angular'; | |
@Injectable() | |
export class SettingsService { | |
private _storage: Storage; | |
private _serverURL: String; | |
constructor() { | |
this._storage = new Storage(SqlStorage); | |
} | |
getServerURL() { | |
let promise = new Promise( | |
(resolve) => { | |
console.log("Promise in SettingsService started"); | |
if (this._serverURL != null && this._serverURL != '') { | |
console.log("Promise in SettingsService resolved, already loaded"); | |
resolve(this._serverURL); | |
} else { | |
this._storage.get("serverURL").then( | |
data => { | |
console.log("Promise in SettingsService resolved, loaded from storage"); | |
resolve(data); | |
} | |
); | |
} | |
} | |
); | |
return promise; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment