angular 2/4 make route standalone

时间:2017-04-29 08:07:46

标签: angular routes

有没有办法可以将路径loginlogincomponent作为独立加载而不需要<router-outlet></router-outlet>

因为AppComponent目前正在其中加载模板,然后我将显示带有<router-outlet></router-outlet>的子页面,但我不希望login成为一个孩子,我希望它是一个独立页面。

编辑: 所有我想要的是登录页面不通过app.component.html,而是我希望它通过另一个模板,因为app.component.html保存我登录的模板。

   import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { FormsModule } from '@angular/forms';
    import { HttpModule } from '@angular/http';
    import { RouterModule } from '@angular/router';



import { AppComponent } from './app.component';
import { CoreService } from './core.service';

import { LoginhandlerComponent } from './loginhandler/loginhandler.component';
import { CoreComponent } from './core/core.component';
import { MinionsComponent } from './minions/minions.component';
import { RegistrationComponent } from './registration/registration.component';

@NgModule({
  declarations: [
    AppComponent,
    LoginhandlerComponent,
    CoreComponent,
    MinionsComponent,
    RegistrationComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot([
      {
        path : 'minions',
        component: MinionsComponent

      },
      {
        path: 'login',
        component: LoginhandlerComponent
      }
        ]

    )
  ],
  providers: [CoreService, ],
  bootstrap: [AppComponent, ]
})
export class AppModule { }

app.component:

<div>

</div>


<router-outlet></router-outlet>

0 个答案:

没有答案