简体   繁体   English

Angular CLI - ng服务

[英]Angular CLI - ng serve

I know that the command "ng serve" creates all my stuff in memory. 我知道命令“ng serve”在内存中创建了我所有的东西。

Now I have such url: http://localhost:4200/some-angular-route But I want this url: http://localhost:4200/ subfolder /some-angular-route 现在我有这样的网址: http:// localhost:4200 / some-angular-route但我想要这个网址: http:// localhost:4200 / subfolder / some-angular-route

My Question is how can I create such a "subfolder"? 我的问题是如何创建这样的“子文件夹”? My Problem is that in my production environment the requests go via Spring Boot Zuul and there are prefixes at urls. 我的问题是,在我的生产环境中,请求通过Spring Boot Zuul进行,并且URL上有前缀。

You can set base href as follows 您可以按如下方式设置基本href

@NgModule({
  imports: [
    RouterModule.forRoot(routes)
  ],
  declarations: [AppComponent],
  providers: [{ provide: APP_BASE_HREF, useValue: '/urlPrefix' }]
})
export class AppModule { }

Also, when you build your code, you can give --directory and --baseHref as follows. 此外,在构建代码时,可以按如下方式给出--directory和--baseHref。

ng build --deploy-url /mySubFolder/ --base-href /urlPrefix/

You can find more here https://github.com/angular/angular-cli/wiki/build 您可以在这里找到更多信息https://github.com/angular/angular-cli/wiki/build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM