文档资料

  • 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions
  • 箭头函数--ES6文档:http://es6.ruanyifeng.com/#docs/function#箭头函数

  • Promise 对象--JS教程:https://wangdoc.com/javascript/async/promise.html
  • Promise--ES6文档:http://es6.ruanyifeng.com/#docs/promise
  • Promise--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise
  • Promise.prototype.then()--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/then

  • 教程:英雄指南:https://www.angular.cn/tutorial#tutorial-tour-of-heroes
  • 工作区与项目文件的结构:https://www.angular.cn/guide/file-structure
  • 组件简介:https://www.angular.cn/guide/architecture-components
  • CLI 命令参考手册:https://www.angular.cn/cli

服务

服务:https://www.angular.cn/tutorial/toh-pt4#services

英雄指南的 HeroesComponent 目前获取和显示的都是模拟数据。

本节课的重构完成之后,HeroesComponent 变得更精简,并且聚焦于为它的视图提供支持。这也让它更容易使用模拟服务进行单元测试。

为什么需要服务

创建 HeroService

@Injectable() 服务

获取英雄数据

提供(provide) HeroService

修改 HeroesComponent

注入 HeroService

添加 getHeroes()

在 ngOnInit 中调用它

可观察(Observable)的数据

可观察对象版本的 HeroService

在 HeroesComponent 中订阅

显示消息

创建 MessagesComponent

创建 MessageService

把它注入到 HeroService 中

从 HeroService 中发送一条消息

从 HeroService 中显示消息

绑定到 MessageService

查看最终代码

Angular记录(7)的更多相关文章

  1. Angular记录(2)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

  2. Angular记录(11)

    开始使用Angular写页面 使用WebStorm:版本2018.3.5 官网资料 资料大部分有中文翻译,很不错 速查表:https://www.angular.cn/guide/cheatsheet ...

  3. Angular记录(10)

    文档资料 速查表:https://www.angular.cn/guide/cheatsheet 风格指南:https://www.angular.cn/guide/styleguide Angula ...

  4. Angular记录(9)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

  5. Angular记录(8)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

  6. Angular记录(6)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

  7. Angular记录(5)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

  8. Angular记录(4)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

  9. Angular记录(3)

    文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...

随机推荐

  1. Canvas 绘图学习笔记2

    1 绘制文本 fillText(string,x,y,maxWidth)  //填充试绘制文本 strokeText(string,x,y,maxWidth) 画线试绘制文本 设置字体样式: cont ...

  2. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  3. docker的基本知识

    Docker 是什么? Docker 是一个开源的应用容器引擎,是基于go语言的,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化. ...

  4. gdb cheat sheet

    0x01 控制流 r run,运行程序. r < a.txt   run,重定向输入 si   step instruction 进入函数 ni      next instruction 下一 ...

  5. 编译装php7.2 && nginx-1.14

    环境准备 # cat /etc/centos-release CentOS Linux release 7.6.1810 (Core) # uname -r 3.10.0-957.el7.x86_64 ...

  6. 类Object

    Object概述 java.lang.Object类是Java语言中的根类,即所有类的父类.它中描述的所有方法子类都可以使用.在对象实例化的时候,最终找的父类就是Object. 如果一个类没有特别指定 ...

  7. 虚拟机网络连接方式导致的p地址为10.0.2.*的问题

    全世界都知道通过 ifconfig 命令查看本机ip地址,我当然希望安装的虚拟机和当前局域网的其他机器一样内网ip为192.168.1.*,如下图所示: 而当我执行该命令时,实际情况却是这样的: 解决 ...

  8. Keil MDK5的ITM调试

    https://blog.csdn.net/burgesskzg/article/details/77100453

  9. Manifest merger failed : Attribute application@icon value=(@mipmap/ic_launcher) from AndroidManifest

    情况是这样子的,导入一个比较老的项目(两年前),它依赖于一个 Libraray,已经先导入了 library,现在导入项目的时候出了错 (1) Android Studio 目前提供将 SDK包成 . ...

  10. 解决Windows10中Virtualbox安装虚拟机没有64位选项

    今天想在Windows 10系统安装完Virtualbox虚拟机,然后打算装一个CENTOS系统,但是选择安装系统的时候竟然没有64位操作系统的选项,经过一阵Google,终于解决了,在这里盘点一下出 ...