如何在 angular 9 中的 http 中传递变量

how to pass variable in http in angular 9

''' how will i add fromDateTime and toDateTime as parameters to be passed in this link.'''

 export function MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {
      const protectedResourceMap = new Map<string, Array<string>>();
      protectedResourceMap.set('https://graph.microsoft.com/v1.0/communications/callRecords/getPstnCalls(fromDateTime=2019-11-01,toDateTime=2019-12-01', ['CallRecords.Read.All','CallRecord-PstnCalls.Read.All','CallRecords.Read.All']);
    
      return {
        interactionType: InteractionType.Redirect,
        protectedResourceMap
      };
    }

您可以利用字符串插值:

let queryUrl = `https://graph.microsoft.com/v1.0/communications/callRecords/getPstnCalls(fromDateTime=${fromDatetimeVariable},toDateTime=${toDatetimeVariable}`

请注意,字符串被反引号 (`) 包围,而不是引号 (')