javascript - How to design a global class for storing settings in Angular? -
i have added class this.
export class settings{ public data: string = "blopp"; } when try access data, seems field i'm trying assign value sees class settings but doesn't recognize data thingy.
how redesign class provide settings other components?
i've read @output decorator since won't binding values, seems not correct approach. i've made sure class imported , recognized withing component that's supposed consume it. i've tried corresponding exposure using function in class settings - same, failed result.
if you're using angular-cli , going store in class environment specific settings - have built in support this.
put setting environment.ts. example:
export const environment = { production: false, somesetting: 'foo', }; then can consumed anywhere within app:
import { environment } "../environments/environment"; //fix according project structure @injectable() export class sampleservice { private foo = environment.somesetting; } here can find more info on how add more environments , build project specific environment settings.
Comments
Post a Comment