我的Angular应用程序中已经配置了HttpClientInMemoryWebApiModule。我想排除一项服务,因此我可以在不添加基础URL的情况下对其进行测试: 问题:
app.module.ts:
# name | preQTxt | qstnLit | ivuInstr
# ------------------------------------------
# question1 |... |... |...
# question2 |... |... |...
# question3 |... |... |...
serviceToExclude.service.ts:
imports: [
BrowserModule,
HttpClientModule,
HttpClientInMemoryWebApiModule.forRoot(InMemHeroService, { rootPath: '/api/'})
],
呼叫链接为: https://localhost/api/http://localhost:4000/users?q=h
而不是: http://localhost:4000/users?q=h
所以我的问题是如何从继承以前的基本URL中排除此服务?
答案 0 :(得分:0)
添加passThrUnknownUrl: app.module.ts:
imports: [
BrowserModule,
HttpClientModule,
HttpClientInMemoryWebApiModule.forRoot(InMemHeroService, {
rootPath: '/api/',
passThruUnknownUrl: true
})
],