でrouterLinkとindex.htmlを
<base href="/">
app.moduleで
が
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { ConnectionService, ownerEnums, requestIdEnums } from './services/connection.service';
import { AuthService } from './services/auth.service';
import { AboutComponent } from './about/about.component';
import { ConnectComponent } from './connect/connect.component';
import { LayoutComponent } from './layout/layout.component';
import { HeaderComponent } from './layout/header/header.component';
import { BreadcrumbComponent } from './layout/breadcrumb/breadcrumb.component';
import { FooterComponent } from './layout/footer/footer.component';
import { IndexComponent } from './layout/index/index.component';
@NgModule({
imports: [
RouterModule.forRoot([
{ path: '', redirectTo: '/index', pathMatch: 'full' },
{ path: 'about', component: AboutComponent },
{ path: 'connect', component: ConnectComponent },
{ path: 'index', component: LayoutComponent }
]),
BrowserModule,
FormsModule,
HttpModule
],
declarations: [
AppComponent,
AboutComponent,
ConnectComponent,
LayoutComponent,
HeaderComponent,
BreadcrumbComponent,
FooterComponent,
IndexComponent
],
providers: [ ConnectionService, AuthService ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
アンカーは
{ path: 'about', component: AboutComponent },
{ path: 'connect', component: ConnectComponent },
{ path: 'index', component: LayoutComponent },
{ path: '', redirectTo: 'index', pathMatch: 'full'},
{path:'**',redirectTo:'index',pathMatch:'full'}
にルーターモジュールを変更します既に試した
はまったく動作しません。 routerLinkをクリックすることなく、無限のURLをすぐに開始します:/ – RickyLeRoi
もっとコードやリンクを共有できますか? –
あなたは役に立つと思いますか? – RickyLeRoi