Using Embedded Data To Provide Request-Specific Application Configuration In Angular 7.2.0
BRANK

Earlier this week, I looked at using the encodeForJavaScript() function in ColdFusion as a way to embed a JSON payload in a page response such that it could provide request-specific configuration for a Single-Page Application (SPA). Today, I want to close the loop on that concept by looking at how to actually consume such a JSON payload as part of the bootstrapping process in an Angular 7.2.0 application. For this exploration, I'm going to be using ColdFusion to produce the configuration data; but, such a technology choice could easily be replaced by your back-end language of choice.Run this demo in my JavaScript Demos project on GitHub.View this code in my JavaScript Demos project on GitHub.Loading configuration data from an embedded page value is not the only way to initialize an Angular application. In fact, just a couple of months ago, I looked at using the APP_INITIALIZER multi-provider in Angular to load configuration data over AJAX (Asynchronous JavaScript and JSON) as part of …

bennadel.com
Related Topics: Angular JavaScript AltJS