Angular 2登录页面,与其他页面的设计不同

我的主要设计通常在app.component.html中.其他组件使用此类主页.但是登录页面将如何具有不同的设计.通常它是一个像其他组件一样的组件(必须?)在app.component.html中工作.

我无法弄清楚.有什么建议?

最佳答案 您的AppComponent应该如下所示.

@Component({
    selector:'payroll-app',
    template:`<div><router-outlet></router-outlet></div>`, //{{}} these four curly braces are called 'interpolation'
    directives: [ROUTER_DIRECTIVES],
    providers: [Utils,BonusService, ModelService, HTTP_PROVIDERS, DialogService]
})

并像这样登录:

@Component({
    templateUrl:'./app/login/login.component.html',
    selector:'app-login',
    styleUrls:['./app/login/login.component.css'],
    directives:[ROUTER_DIRECTIVES]
})

保持默认路线如:

LoginRoutes = [
    { path: 'login', component: LoginComponent},
    {path: '', redirectTo: '/login', pathMatch: 'full'}
]

当您的页面将被加载时,路由器服务将默认将您的应用程序重定向到登录页面.这是通常的应用程序的工作方式

点赞