App Wide Variable


#1

So im sure this is something simple, but im not sure how to approach it in ionic2. I want to set an app wide variable. I can set it and load it in local storage /sql storage each time i need it, i was just wonder if there was a better way to do that?

For example, i want to force the user to pick a location from a drop down, and use that setting everywhere in the app


#2

You could set a variable on a injectable class en inject that in every page/class you need. Something in the line of

import {Injectable} from "angular2/core";

@Injectable()
export class DataService {
    
    dropdownValue: string;
    constructor() { }

}