app.module.ts

import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core'; import {AppComponent} from './app.component';
import {NavBarComponent} from './nav-bar/nav-bar.component';
import {FooterComponent} from './footer/footer.component';
import {SearchComponent} from './search/search.component';
import {ProductComponent} from './product/product.component';
import {CarouselComponent} from './carousel/carousel.component';
import {StarsComponent} from './stars/stars.component';
import {HomeComponent} from './home/home.component';
import {RouterModule, Routes} from '@angular/router';
import {Code404Component} from './code404/code404.component';
import { LoginComponent } from './login/login.component'; const routes: Routes = [
{path: '', redirectTo: '/home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'login', component: LoginComponent},
{path: '**', component: Code404Component}
]; @NgModule({
declarations: [
AppComponent,
NavBarComponent,
FooterComponent,
SearchComponent,
ProductComponent,
CarouselComponent,
StarsComponent,
HomeComponent,
Code404Component,
LoginComponent
],
imports: [
BrowserModule,
RouterModule.forRoot(routes)
],
exports: [RouterModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}

app-nav-bar.component.heml update

<li><a routerLink="/home">首页</a></li>
      <ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a routerLink="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>

login.component.html

<div class="container">
<div class="main-box col-md-6 col-md-offset-3"> <div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Login</div>
</div> <div style="padding:30px" class="panel-body">
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
<form class="form-horizontal" role="form">
<label style="padding-bottom:10px" class="control-label">UserName</label>
<div style="margin-bottom: 15px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" class="form-control" name="username" placeholder="username or email">
</div>
<label style="padding-bottom:10px" class="control-label">Password</label>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input type="password" class="form-control" name="password" placeholder="password">
</div>
<div style="margin-top:10px" class="form-group">
<div class="col-sm-12 controls">
<a id="btn-login" href="#" class="btn btn-success">Login</a>
</div>
</div>
</form>
</div>
</div> </div>
</div>

home.component.html

<div class="container">
<div class="row">
<div class="col-md-3">
<app-search></app-search>
</div>
<div class="col-md-9">
<div class="row">
<app-carousel></app-carousel>
</div>
<div class="row">
<app-product></app-product>
</div>
</div>
</div>
</div>

update app.component.html

<app-nav-bar></app-nav-bar>

<router-outlet></router-outlet>

<app-footer></app-footer>

@angular/cli项目构建--路由1的更多相关文章

  1. @angular/cli项目构建--路由3

    路由定位: modifyUser(user) { this.router.navigate(['/auction/users', user.id]); } 路由定义: {path: 'users/:i ...

  2. @angular/cli项目构建--路由2

    app.module.ts update const routes: Routes = [ {path: '', redirectTo: '/home', pathMatch: 'full'}, {p ...

  3. @angular/cli项目构建--组件

    环境:nodeJS,git,angular/cli npm install -g cnpm --registry=https://registry.npm.taobao.org cnpm instal ...

  4. @angular/cli项目构建--modal

    环境准备: cnpm install ngx-bootstrap-modal --save-dev impoerts: [BootstrapModalModule.forRoot({container ...

  5. @angular/cli项目构建--Dynamic.Form

    导入所需模块: ReactiveFormsModule DynamicFormComponent.html <div [formGroup]="form"> <l ...

  6. @angular/cli项目构建--animations

    使用方法一(文件形式定义): animations.ts import { animate, AnimationEntryMetadata, state, style, transition, tri ...

  7. @angular/cli项目构建--interceptor

    JWTInterceptor import {Injectable} from '@angular/core'; import {HttpEvent, HttpHandler, HttpInterce ...

  8. @angular/cli项目构建--httpClient

    app.module.ts update imports: [ HttpClientModule] product.component.ts import {Component, OnInit} fr ...

  9. @angular/cli项目构建--Dynamic.Form(2)

    form-item-control.service.ts update @Injectable() export class FormItemControlService { constructor( ...

随机推荐

  1. Android 开发之:Intent.createChooser() 妙用

    大家对该功能第一印象就是ApiDemo 里面的 其只有区区几行代码  提取为: Intent intent = new Intent(Intent.ACTION_GET_CONTENT); inten ...

  2. ModelForm组件介绍

    照抄自:http://www.jb51.net/article/126786.htm ModelForm组件如同它的名字一样就是把model和form结合起来,在有些场景可以起到意想不到的效果. 先来 ...

  3. python常用模块——sys模块

    sys模块的功能很多,下面介绍几个常用的模块. 1.sys.argv:从外部向程序内部传递参数 #!/usr/bin/env python import sys print(sys.argv[0]) ...

  4. pycharm一直scanning files to index

    删除了c盘的垃圾文件之后,pycharm就一直scanning files to index 解决方法: 点击file,然后选择invalidate caches / restart ...,再弹出的 ...

  5. 常见Web源码泄露总结

    来自:http://www.hacksec.cn/Penetration-test/474.html 摘要 背景 本文主要是记录一下常见的源码泄漏问题,这些经常在web渗透测试以及CTF中出现. .h ...

  6. Loadrunner脚本篇——从文件中读取内容并参数化

    直接代码展示: char* testfn() { int count, total = 0; char * buffer = NULL; int filelenth = 0; long file_st ...

  7. window.name跨域

    window.name? 每一个页面都有一个自己的window,而window.name是window的名字. window.name跨域原理 window对象有个name属性,该属性有个特征:即在一 ...

  8. 树莓派使用DHT11温湿度传感器(C语言)

    硬件: 树莓派 2.0 DHT模块  接树莓派5V GND GPIO1 功能:读取传感器数据并打印出来 // //mydht11.c // #include <wiringPi.h> #i ...

  9. 【leetcode刷题笔记】Minimum Window Substring

    Given a string S and a string T, find the minimum window in S which will contain all the characters ...

  10. Docker容器技术-基础与架构

    一.什么是容器 容器是对应用程序及其依赖关系的封装. 1.容器的优点 容器与主机的操作系统共享资源,提高了效率,性能损耗低 容器具有可移植性 容器是轻量的,可同时运行数十个容器,模拟分布式系统 不必花 ...