Angular记录(7)
文档资料
- 箭头函数--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)的更多相关文章
- Angular记录(2)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
- Angular记录(11)
开始使用Angular写页面 使用WebStorm:版本2018.3.5 官网资料 资料大部分有中文翻译,很不错 速查表:https://www.angular.cn/guide/cheatsheet ...
- Angular记录(10)
文档资料 速查表:https://www.angular.cn/guide/cheatsheet 风格指南:https://www.angular.cn/guide/styleguide Angula ...
- Angular记录(9)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
- Angular记录(8)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
- Angular记录(6)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
- Angular记录(5)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
- Angular记录(4)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
- Angular记录(3)
文档资料 箭头函数--MDN:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_fun ...
随机推荐
- linux下mysql配置文件位置
在/usr/share/mysql/ 中找到my.cnf的配置文件,拷贝其中的my-huge.cnf 到 /etc/ 并命名为my.cnf
- [20190419]shared latch spin count 2.txt
[20190419]shared latch spin count 2.txt --//上午测试shared latch XX模式的情况,链接:http://blog.itpub.net/267265 ...
- delphi中WMI的使用(网卡是否接入)
WMI(Windows Management Instrumentation,Windows 管理规范)是一项核心的 Windows 管理技术:用户可以使用 WMI 管理本地和远程计算机. 通过使用W ...
- DVWA-暴力破解学习笔记
DVWA-暴力破解 1.暴力破解 2.burp安装证书 3.万能密码 一.暴力破解 burp四种暴力破解类型: sniper 一个字典,两个参数,先匹配第一项再匹配第二项 Battering ra ...
- windows10+VS+CUDA+cuDNN+TensorFlow-gpu环境搭建(问题及解决)
TensorFlow-gpu环境需要CUDA+cuDNN+python,CUDA又需要VS,所以,,,环境越来越大哈哈. 1.主要环境: Python 3.6 CUDA9.0 Cudann7.0 Te ...
- C# -- 泛型的使用
C# -- 泛型的使用 1. 使用泛型 class Program { static void Main(string[] args) { ; string str = "Hello&quo ...
- monkey常用命令实例
一.常用命令的使用 1.monkey进行压力测试的命令是什么呢? adb shell monkey -p <packagename> <count> eg: adb shell ...
- ckeditor django admin 中使用
ckeditor settings配置 ############ # CKEDITOR # ############ MEDIA_ROOT = os.path.join(BASE_DIR, 'medi ...
- Pandas 数据清洗常用篇
一.缺失值 sklearn中的preprocessing下有imputer,可进官方文档参考.这里主讲pandas. 拿到数据,一般先检查是否有缺失值,用isnul()或notnull(). 再决定d ...
- 如何注册一个google账号
注册过google账号的人都知道,在注册的过程中会需要短信验证. 可我大天朝偏偏连这个都锁了,导致根本验证不了. 所以,经过网上方法的不断尝试,排除了很多的方法:例如使用qq邮箱注册等,现在已经不能用 ...