接着第一部分,这篇文章就 Angular cli进行介绍总结:

1. ng g:列出当前命令

ng g

需在angular工程文件夹下执行:

C:\Users\zb\angulardemo\heroes>ng g
Generates and/or modifies files based on a schematic.
usage: ng generate <schematic> [options] arguments:
schematic
The schematic or collection:schematic to generate. options:
--defaults
When true, disables interactive input prompts for options with a default.
--dry-run (-d)
When true, runs through and reports activity without writing out results.
--force (-f)
When true, forces overwriting of existing files.
--help
Shows a help message for this command in the console.
--interactive
When false, disables interactive input prompts. Available Schematics:
Collection "@schematics/angular" (default):
appShell
application
class
component
directive
enum
guard
interface
library
module
pipe
service
serviceWorker
universal

2.  ng generate component component-name:该命令会把生成的组件,

     添加到 src/app/app.module.ts 文件中 @NgModule 的 declarations 列表中声明:

3. ng generate service: 创建服务文件

ng generate service hero

该命令会在 src/app/hero.service.ts 中生成 HeroService 类的骨架。 HeroService类的代码如下:

import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root',
})
export class HeroService { constructor() { } } 

4. ng generate module app-routing --flat --module=app:添加 AppRoutingModule

ng generate module app-routing --flat --module=app
  • --flat 把这个文件放进了 src/app 中,而不是单独的目录中。
  • --module=app 告诉 CLI 把它注册到 AppModule的 imports 数组中。
生成的代码如下:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; @NgModule({
imports: [
CommonModule
],
declarations: []
})
export class AppRoutingModule { }
 

Angular7.1.4+Typescript3.1框架学习(二)的更多相关文章

  1. Angular7.1.4+Typescript3.1框架学习(一)

    起因:学习ionic4之前先学习下angular+ts 以win10为开发平台:当前最新版本为angular7;根据官网资料做如下总结: 1. angular安装 前提:Node.js 的 8.x 或 ...

  2. Angular7.1.4+Typescript3.1框架学习(三)

    接着第二部分,这部分介绍常见angular指令使用 1. 在父页面文件中添加组件(通过ng命令生成的component) <app-messages></app-messages&g ...

  3. Struts2框架学习(二) Action

    Struts2框架学习(二) Action Struts2框架中的Action类是一个单独的javabean对象.不像Struts1中还要去继承HttpServlet,耦合度减小了. 1,流程 拦截器 ...

  4. Android 学习笔记之AndBase框架学习(二) 使用封装好的进度框,Toast框,弹出框,确认框...

    PS:渐渐明白,在实验室呆三年都不如在企业呆一年... 学习内容: 1.使用AbActivity内部封装的方法实现进度框,Toast框,弹出框,确认框...   AndBase中AbActivity封 ...

  5. WebGL------osg框架学习二

    今天我们继续来学习osg.js框架.上一篇我们介绍了DrawActor对象绘制操作类和Drawable可绘制对象类,我们大致知道了osg对Drawable可绘制对象的绘制流程管理.今天我们要继续介绍S ...

  6. Hibernate框架学习(二)——api详解

    一.Configuration对象 功能:配置加载类,用于加载主配置,orm元数据加载. //1.创建,调用空参构造(还没有读配置文件) Configuration conf=new Configur ...

  7. python flask框架学习(二)——第一个flask程序

    第一个flask程序 学习自:知了课堂Python Flask框架——全栈开发 1.用pycharm新建一个flask项目 2.运行程序 from flask import Flask # 创建一个F ...

  8. Castle ActiveRecord框架学习(二):快速搭建简单博客网站

    一.数据库 1.数据表 Category:类别标签表(字段Type=1为类别,Type=2为标签) Category_Post:类别标签与文章中间表 Post:文章表 Comment:评论表 2.数据 ...

  9. Spring框架学习(二)

    一.依赖注入的三种注入方式 Spring框架为我们提供了三种注入方式:set注入.构造方法注入和接口注入. 1.set注入 规律:无论给什么赋值,配置文件中<property>标签的nam ...

随机推荐

  1. Visual Studio Git本地Repos和GitHub远程Repos互操作

    近期准备将一个项目开源到GitHub中,N-Sharding,.Net版本的分库分表数据访问框架.中间遇到了点小问题,整理了一下. 1. GitHub上Create New Repos 2. 代码Ch ...

  2. 【转】git示意图

  3. liunx驱动----系统滴答时钟的使用

    2019-3-12系统滴答定时器中断使用 定义一个timer ​​ 其实就是使用系统的滴答定时器产生一个中断. 初始化timer init_timer函数 实现如下 void fastcall ini ...

  4. CCF CSP 201312-1 出现次数最多的数

    题目链接:http://118.190.20.162/view.page?gpid=T5 问题描述 试题编号: 201312-1 试题名称: 出现次数最多的数 时间限制: 1.0s 内存限制: 256 ...

  5. C# Thread.Jion()

    什么是进程? 当一个程序开始运行时,它就是一个进程,进程包括运行中的程序和程序所使用到的内存和系统资源. 而一个进程又是由多个线程所组成的. 什么是线程? 线程是程序中的一个执行流,每个线程都有自己的 ...

  6. Linux 主要目录速查表

    /:根目录,一般根目录下只存放目录,在 linux 下有且只有一个根目录,所有的东西都是从这里开始 当在终端里输入 /home,其实是在告诉电脑,先从 /(根目录)开始,再进入到 home 目录 /b ...

  7. asp.net core 使用 web deploy 部署网站

    1.添加角色和功能中 web服务器(iis)->管理工具->管理服务  打勾并安装 2.安装 web deploy,也可以通过 web平台安装程序 来安装,搜索web deploy就可以了 ...

  8. FL studio里的项目设置介绍

    FL studio作为具有众多音乐功能,能够制作多轨音频录制,排序和混音的一款专业软件,我们可以借助VST主机,灵活的调音台,高级MIDI和ReWire支持,来创建专业品质的各种音乐曲目. 而今天我们 ...

  9. JS的深度克隆,利用构造函数原型深度克隆

    我爱撸码,撸码使我感到快乐!大家好,我是Counter.今天来写写,JS中的深度克隆,这个在笔面试中,考的还是比较多的,主要是对象与数组的赋值,如果直接赋值的话,那么得到的是对象或者数组在堆里的地址, ...

  10. Bootstrap3基础 栅格系统 标尺(col-lg/md/sm/xs-1)

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...