Angular7.1.4+Typescript3.1框架学习(二)
接着第一部分,这篇文章就 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框架学习(二)的更多相关文章
- Angular7.1.4+Typescript3.1框架学习(一)
起因:学习ionic4之前先学习下angular+ts 以win10为开发平台:当前最新版本为angular7;根据官网资料做如下总结: 1. angular安装 前提:Node.js 的 8.x 或 ...
- Angular7.1.4+Typescript3.1框架学习(三)
接着第二部分,这部分介绍常见angular指令使用 1. 在父页面文件中添加组件(通过ng命令生成的component) <app-messages></app-messages&g ...
- Struts2框架学习(二) Action
Struts2框架学习(二) Action Struts2框架中的Action类是一个单独的javabean对象.不像Struts1中还要去继承HttpServlet,耦合度减小了. 1,流程 拦截器 ...
- Android 学习笔记之AndBase框架学习(二) 使用封装好的进度框,Toast框,弹出框,确认框...
PS:渐渐明白,在实验室呆三年都不如在企业呆一年... 学习内容: 1.使用AbActivity内部封装的方法实现进度框,Toast框,弹出框,确认框... AndBase中AbActivity封 ...
- WebGL------osg框架学习二
今天我们继续来学习osg.js框架.上一篇我们介绍了DrawActor对象绘制操作类和Drawable可绘制对象类,我们大致知道了osg对Drawable可绘制对象的绘制流程管理.今天我们要继续介绍S ...
- Hibernate框架学习(二)——api详解
一.Configuration对象 功能:配置加载类,用于加载主配置,orm元数据加载. //1.创建,调用空参构造(还没有读配置文件) Configuration conf=new Configur ...
- python flask框架学习(二)——第一个flask程序
第一个flask程序 学习自:知了课堂Python Flask框架——全栈开发 1.用pycharm新建一个flask项目 2.运行程序 from flask import Flask # 创建一个F ...
- Castle ActiveRecord框架学习(二):快速搭建简单博客网站
一.数据库 1.数据表 Category:类别标签表(字段Type=1为类别,Type=2为标签) Category_Post:类别标签与文章中间表 Post:文章表 Comment:评论表 2.数据 ...
- Spring框架学习(二)
一.依赖注入的三种注入方式 Spring框架为我们提供了三种注入方式:set注入.构造方法注入和接口注入. 1.set注入 规律:无论给什么赋值,配置文件中<property>标签的nam ...
随机推荐
- CentOS7 安装 MySQL8.0
[1]安装步骤过程 (1)yum仓库下载MySQL 命令:yum localinstall https://repo.mysql.com//mysql80-community-release-el7- ...
- (Review cs231n) Spatial Localization and Detection(classification and localization)
重在图像的定位和检测的内容. 一张图片中只有一种给定类别标签的对象,定位则是图像中有对象框:再这些类中,每一个训练目标都有一个类和许多的图像内部对应类的位置选框. 猜想的仅是类标签,不如说它们是位置 ...
- Oarcle 之连接查询
连接查询:连接查询是关系数据库中最主要的查询,主要包括内连接.外连接和交叉连接等.通过连接运算符可以实现多个表查询.连接是关系数据库模型的主要特点,也是它区别于其它类型数据库管理系统的 ...
- winform Combobox出现System.Data.DataRowView的解决的方法
个人总结: 1.触发了SelectedIndexChanged事件时:comboBox1.DataSource = dt;要放在comboBox1.SelectedIndex = 0;的上面 comb ...
- redis注册为window服务
打开redis安装路径并执行:redis-server --service-install redis.windows.conf 安装服务命令 执行完命令后打开电脑服务 此时服务还未启动,执行命令:r ...
- 对八皇后的补充以及自己解决2n皇后问题代码
有了上次的八皇后的基础.这次准备解决2n皇后的问题,: //问题描述// 给定一个n*n的棋盘,棋盘中有一些位置不能放皇后.现在要向棋盘中放入n个黑皇后和n个白皇后,使任意的两个黑皇后都不在同一行./ ...
- Linux服务器 XAMPP后添加PHP和MYSQL环境变量
编辑/etc/profile文件 在文件末尾添加两行代码 vi /etc/profile CentOS: PATH=$PATH:/opt/lampp/bin export PATH Ubuntu: e ...
- oracle传输表空间相关
1.convert tablespaceconvert tablespace源端库执行:convert tablespace 'TPS_DATA' to platform 'AIX-Based Sys ...
- python 包 笔记
绝对导入和相对导入 我们的最顶级包glance是写给别人用的,然后在glance包内部也会有彼此之间互相导入的需求,这时候就有绝对导入和相对导入两种方式: 绝对导入:以glance作为起始 相对导入: ...
- ERROR: Got error reading packet from server: A slave with the same server_uuid/server_id as this slave has connected to the master
centos7.5 做binlog-server,拉取主库binlog报错 问题: [root@db03-53 binlog]# mysqlbinlog -R --host=10.0.0.55 --u ...