参照 草根专栏- ASP.NET Core + Ng6 实战:https://v.qq.com/x/page/b076702elvw.html

安装工具:

  1. Nodejs, npm     最新版, https://nodejs.org/en/
  2. Angular CLI,    npm install -g @angular/cli
  3. Visual Studio Code,    https://code.visualstudio.com/

Angular Cli

  1. https://github.com/angular/angular-cli
  2. https://cli.angular.io/
  3. ng new
  4. ng generate
  5. ng serve
  6. Test, Lint, Format
  7. 要看文档!!!

项目搭建

1、在cmd  输入  ng new blog-client  --style scss  --dry-run   项目创建预览

2、在项目目录下输入 code .   命令打开vscode

3、 安装 angularMaterial       npm install --save @angular/material @angular/cdk @angular/animations         官网 :https://material.angular.io/guides

4、 在 app.module.ts 中添加

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

@NgModule({
...
imports: [BrowserAnimationsModule],
...
})
export class PizzaPartyAppModule { }

5、在 app.module.ts 中添加

import {MatButtonModule, MatCheckboxModule} from '@angular/material';

@NgModule({
...
imports: [MatButtonModule, MatCheckboxModule],
...
})
export class PizzaPartyAppModule { }

6、在scss中添加

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

7、npm install --save hammerjs      在main.ts 导入

import 'hammerjs';

8、 ng g module blog --routing --spec false

9、全局设置 spec为false,在angular.json中设置

        "@schematics/angular:module": {
"spec": false
}

10、 ng g module shared/material    将angularMateria组件都导入

11、将  MaterialModule 导入  blog.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MaterialModule} from '../shared/material/material.module'
import { BlogRoutingModule } from './blog-routing.module'; @NgModule({
imports: [
CommonModule,
BlogRoutingModule,
MaterialModule
],
declarations: []
})
export class BlogModule { }

12、 ng g component blog/blog-app --flat --inline-style  --inline-template --module blog   创建主组件

13、配置路由:blog-routing.module.ts

const routes: Routes = [
{path: '', component: BlogAppComponent}
]; @NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BlogRoutingModule { }

13、配置主路由:app.module.ts

const routers: Routes = [
{path: 'blog', loadChildren: './blog/blog.module#BlogModule'},
{path: '**' , redirectTo: 'blog' }
]; @NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule, BrowserAnimationsModule, MatButtonModule, MatCheckboxModule,
RouterModule.forRoot(routers)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

14、配置路由插座:app.component.html

<router-outlet></router-outlet>

15、ng g c blog/components/sidenav

16、ng g c blog/components/toolbar

17、 导入图标:blog-app.component.ts

export class BlogAppComponent implements OnInit {
constructor(iconRegistry: MatIconRegistry, sanitizer: DomSanitizer) {
iconRegistry.addSvgIcon('baseline-more_vert', sanitizer.bypassSecurityTrustResourceUrl('/assets/baseline-more_vert-24px.svg'));
iconRegistry.addSvgIcon('baseline-menu', sanitizer.bypassSecurityTrustResourceUrl('/assets/baseline-menu-24px.svg'));
}
ngOnInit() {
}

18、在app.module.ts 中添加   HttpClientModule

图标下载网站:https://material.io/tools/icons/?icon=more_vert&style=baseline

Angular6项目搭建的更多相关文章

  1. Intellij IDEA Java web 项目搭建

    Java web 项目搭建 简介 在上一节java web环境搭建中,我们配置了开发java web项目最基本的环境,现在我们将采用Spring MVC+Spring+Hibernate的架构搭建一个 ...

  2. 项目搭建系列之一:使用Maven搭建SpringMVC项目

    约定电脑都安装了eclipse,且已配置好Maven以及eclipse插件. 1.Eclipse 2.maven 3.Eclipse 需要安装maven插件.url:maven - http://do ...

  3. maven项目搭建

    一.Maven简介 Maven是基于Java平台的项目构建(mvn clean install).依赖管理(中央仓库,Nexus)和项目信息管理的项目管理工具. Maven是基于项目对象模型(POM) ...

  4. maven3常用命令、java项目搭建、web项目搭建详细图解

    http://blog.csdn.net/edward0830ly/article/details/8748986 ------------------------------maven3常用命令-- ...

  5. Java web 项目搭建

    Java web 项目搭建 简介 在上一节java web环境搭建中,我们配置了开发java web项目最基本的环境,现在我们将采用Spring MVC+Spring+Hibernate的架构搭建一个 ...

  6. requirejs + vue 项目搭建2

    上篇是年后的项目搭建的,时间比较仓促,感觉有点low 1.gulp-vue 文件对公用js的有依赖,以后别的同事拿去搭其他项目,估计会被喷 2.不支持vue-loader一样写模版语言和es6语法 最 ...

  7. requirejs + vue 项目搭建

    以前都是支持 司徒正美 的,毕竟咱们也是跟着 司徒正美 一起走进了前端的世界.所以一般MVVM都是用avalon的,当然也是考虑到项目需要支持IE6,7,8的考虑.当然在用的时候也有一些小坑和bug, ...

  8. Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建(转)

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 如果还没有搭建好环境( ...

  9. freemarker + spring mvc + spring + mybatis + mysql + maven项目搭建

    今天说说搭建项目,使用freemarker + spring mvc + spring + mybatis + mysql + maven搭建web项目. 先假设您已经配置好eclipse的maven ...

随机推荐

  1. 十四、详述 IntelliJ IDEA 提交代码前的 Code Analysis 机制

    在我们用 IntelliJ IDEA 向 SVN 或者 Git 提交代码的时候,IntelliJ IDEA 提供了一个自动分析代码的功能,即Perform code analysis: 如上图所示,当 ...

  2. Hadoop 学习之——HDFS

    HDFS是HADOOP中的核心技术之一——分布式文件存储系统.Hadoop的作者Doug Cutting 和Mike 是根据Google发布关于GFS 的研究报告所设计出的分布式文件存储系统. 一.H ...

  3. angular1的复选框指令--checklistModel

    这个指令可以改变一组checkbox的model格式,提交的时候格式为[x,y,z,...] //复选框指令 .directive('checklistModel', ['$parse', '$com ...

  4. 设计一个方法injectBeforeAsyncSend,能够实现如下功能:在发起异步请求之前打印出请求的类型、URL、method、body、timestamp 等信息。

    异步请求逻辑注入 工作中我们需要对异步请求的请求信息打印日志,但是又不能耦合在业务代码中打印.请设计一个方法injectBeforeAsyncSend,能够实现如下功能:在发起异步请求之前打印出请求的 ...

  5. 协议类接口 - SPI

     一.SPI概述 SPI(Serial Peripheral Interface,串行外设接口)总线系统是一种同步串行外设接口,它可以使CPU与各种外围设备以串行方式进行通信以交换信息.一般主控SoC ...

  6. DML-修改

    一, 修改单表的记录 语法: update 表名 set 字段=值[where 筛选条件] 二,修改多表 update 表名 别名 inner/left/rigth join 表二 on 连接条件 s ...

  7. 二、HDFS 架构

    源自:http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html HDFS has a m ...

  8. 【Linux资源管理】使用sar进行性能分析

    sar可用于监控Linux系统性能,帮助我们分析性能瓶颈.sar工具的使用方式为”sar [选项] intervar [count]”,其中interval为统计信息采样时间,count为采样次数. ...

  9. mysql 一看就会 基本语法

    创建表 create table <表名>( <字段名>  类型(长度) not null primary key auto_increment, **主键 name char ...

  10. 剑指Offer_编程题之替换空格

    题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy.