Created
March 24, 2021 05:47
-
-
Save pablotolentino/44b899b0574dacdc3dbdf38ee5a89e7f to your computer and use it in GitHub Desktop.
AppComponent completo
This file contains hidden or 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
export class AppComponent implements OnInit { | |
constructor(private httpClient: HttpClient) { | |
} | |
private config: {version: string}; | |
ngOnInit() { | |
this.config = require("./../assets/config.json"); | |
console.log(this.config.version); | |
const headers = new HttpHeaders() | |
.set('Cache-Control', 'no-cache') | |
.set('Pragma', 'no-cache'); | |
this.httpClient | |
.get<{ version: string }>("/assets/config.json", {headers}) | |
.subscribe(config => { | |
if (config.version !== this.config.version) { | |
location.reload(true); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment