添加上下文路径 Angular 2
Add context path Angular 2
我想 运行 我的应用而不是 http://localhost:4200 at http://localhost:4200/pilot/。
我正在尝试更改 index.html 处的基本 href,但我收到未捕获的语法错误:意外令牌 <
这是我的index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PrimengQuickstartCli</title>
<base href="pilot/"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>
还有我的app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { MessagesModule } from 'primeng/primeng';
import { InputTextModule } from 'primeng/primeng';
import { PasswordModule } from 'primeng/primeng';
import { ButtonModule } from 'primeng/primeng';
import { DataTableModule, SharedModule } from 'primeng/primeng';
import { DialogModule } from 'primeng/primeng';
import { CarService } from './service/carservice';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ButtonModule,
MessagesModule,
InputTextModule,
PasswordModule,
ReactiveFormsModule,
DataTableModule,
SharedModule,
DialogModule
],
providers: [CarService],
bootstrap: [AppComponent]
})
export class AppModule { }
我应该更改文件夹结构吗?
感谢任何帮助。
你可以使用 angular 中的路由模块 2 并在 url 中未设置路径时将用户重定向到 /pilot
所以你将在 app.routing.ts 中有这样的代码
{path: '',redirectTo: '/pilot',pathMatch: 'full'},
仍然需要看看这是否可以在没有路由的情况下完成。
最后在我的 index.html:
<base href="/pilot/">
我想 运行 我的应用而不是 http://localhost:4200 at http://localhost:4200/pilot/。
我正在尝试更改 index.html 处的基本 href,但我收到未捕获的语法错误:意外令牌 <
这是我的index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PrimengQuickstartCli</title>
<base href="pilot/"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>
还有我的app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { MessagesModule } from 'primeng/primeng';
import { InputTextModule } from 'primeng/primeng';
import { PasswordModule } from 'primeng/primeng';
import { ButtonModule } from 'primeng/primeng';
import { DataTableModule, SharedModule } from 'primeng/primeng';
import { DialogModule } from 'primeng/primeng';
import { CarService } from './service/carservice';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ButtonModule,
MessagesModule,
InputTextModule,
PasswordModule,
ReactiveFormsModule,
DataTableModule,
SharedModule,
DialogModule
],
providers: [CarService],
bootstrap: [AppComponent]
})
export class AppModule { }
我应该更改文件夹结构吗?
感谢任何帮助。
你可以使用 angular 中的路由模块 2 并在 url 中未设置路径时将用户重定向到 /pilot 所以你将在 app.routing.ts 中有这样的代码 {path: '',redirectTo: '/pilot',pathMatch: 'full'},
仍然需要看看这是否可以在没有路由的情况下完成。
最后在我的 index.html:
<base href="/pilot/">