Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Typescript从appsettings填充字符串模板_Angular_Typescript_String Formatting_String Interpolation - Fatal编程技术网

Angular Typescript从appsettings填充字符串模板

Angular Typescript从appsettings填充字符串模板,angular,typescript,string-formatting,string-interpolation,Angular,Typescript,String Formatting,String Interpolation,想法是在appSettings.json中有一个模板字符串: "AppSettings": { "PretendUri": "http://devEnvSite/blahBah/{0}/get", ... 原因是此Uri因环境而异 然后,我想在运行时用一个有意义的/动态值填充{0}的几个控制器中使用invokeURI属性 在C#中,我通常使用String.Format(),但在Typescript中,我发现这不是需要使用插值的情况 有什么建议吗?字符串替换 "http://d

想法是在appSettings.json中有一个模板字符串:

"AppSettings": {
    "PretendUri": "http://devEnvSite/blahBah/{0}/get",
     ...
原因是此Uri因环境而异

然后,我想在运行时用一个有意义的/动态值填充{0}的几个控制器中使用invokeURI属性

在C#中,我通常使用String.Format(),但在Typescript中,我发现这不是需要使用插值的情况


有什么建议吗?

字符串替换

"http://devEnvSite/blahBah/{0}/get".replace(/{.*}/, "myCustomValue")
或者可能在您的代码中,类似于:

appSettings.PretendUri.replace(/{.*}/, "myCustomValue")