'Convert json string to interpolation in angular
I have a json response as :
{ someText: "Order in {000} 12pm PST for early shipping"; cutofftime : "10000000" }
What is the best approach to replace the '{000}' by the "cutofftime". Here the cutofftime is dynamic and the "someText" is static. I am using Angular 12.
I tried :
this.orderCutOffMessage = Order in ${{ cutofftime }} 12pm PST for early shipping;
which does not work and also the first and last part of the this.orderCutOffMessage should also come from the json response,
Solution 1:[1]
this.orderCutOffMessage = (yourJSONresponseVar).someText.replace('{000}',(yourJSONresponseVar).cutofftime);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Misha Mashina |
