import { Component, OnInit } from '@angular/core'; import { LanguageService } from './language.service'; import { LanguageData } from './language.model'; //import { Post} from './posts/post.model'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'ZGo'; zgoLanguage:string = ''; vE = { mainPriceData : '' } constructor( private languageService: LanguageService){ } ngOnInit(){ console.log('chgUILanguage() called on ngOnInit '); this.chgUILanguage(); } chgUILanguage() { console.log('MAIN.chgUILanguage Called '); this.languageService.getViewElements('main').subscribe( response => { console.log('response >> ', response ); console.log('main_price_data -> ',response.data.main_price_data); this.vE.mainPriceData = response.data.main_price_data; this.zgoLanguage = response.language; }, error => { console.log('Error --> ',error); } ); } usFlagClicked() { if ( this.zgoLanguage != 'en-US' ) { localStorage.setItem('zgo_language','en-US'); window.location.reload(); } } esFlagClicked() { if ( this.zgoLanguage != 'es-US' ) { localStorage.setItem('zgo_language','es-US'); window.location.reload(); } } brFlagClicked() { if ( this.zgoLanguage != 'br-US' ) { localStorage.setItem('zgo_language','br-US'); window.location.reload(); } } }