5.6 Components -- Handling User Interaction with Actions
1. 组件允许你定义可以在整个应用程序中重用的控件。如果它们够通用,它们也可以在被共享给其他人并且在许多应用程序中被使用。
2. 为了使一个可重用的控件有用,然而,你首先需要你的应用程序的用户和它交互。
3. 你可以通过使用{{action}}辅助器使组件中的元素可交互。这和应用程序templates中的{{action}}一样,但是当在模板内部使用时有一个重要的区别。
4. 而不是像模板的控制器发送一个action,然后冒泡到路由层次,来自模板内部的actions被直接发送到模板的Ember.Component实例,并且不会冒泡。
5. 例如,假设下面的组件显示一个post的标题,当这个标题被点击,整个post的内容会被显示:
app/templates/components/post-summary.hbs
<h3 {{action "toggleBody"}}>{{title}}</h3>
{{#if isShowingBody}}
<p>{{{body}}}</p>
{{/if}}
app/components/post-summary.js
export default Ember.Component.extend({
actions: {
toggleBody() {
this.toggleProperty('isShowingBody');
}
}
});
{{action}}辅助器可以接收参数,监听不同的事件类型,控制如何发生冒泡,还有更多。
5.6 Components -- Handling User Interaction with Actions的更多相关文章
- Ember.js学习教程 -- 目录
写在前面的话: 公司的新项目需要用到Ember.js,版本为v1.13.0.由于网上关于Ember的资料非常少,所以只有硬着头皮看官网的Guides,为了加深印象和方便以后查阅就用自己拙劣的英语水平把 ...
- 【转】(五)unity4.6Ugui中文教程文档-------概要-UGUI Interaction Components
原创至上,移步请戳:(五)unity4.6Ugui中文教程文档-------概要-UGUI Interaction Components 4.Interaction Components 本节涵盖了处 ...
- Event Handling Guide for iOS--(二)---Gesture Recognizers
Gesture Recognizers 手势识别器 Gesture recognizers convert low-level event handling code into higher-leve ...
- nginx---reference
nginx (pronounced "engine x") is a free open source web server written by Igor Sysoev, a R ...
- JDWP Agent
JDWP Agent Implementation Description Revision History Disclaimer 1. About this Document 1.1 Purpose ...
- Atitit WebDriver技术规范原理与概念
Atitit WebDriver技术规范原理与概念 1. Book haosyo ma1 2. WebDriver是W3C的一个标准,由Selenium主持.1 3. WebDriver如何工作 (z ...
- The Unified Modeling Language(UML)
统一过程建模语言UML 统一过程建模语言UML是一种标准的可视化建模语言,使用在: 业务建模和类似的过程 居于软件系统的分析.设计.和实现 UML 是一门通用语言,提供给业务分析员,软件架构师和开发 ...
- Implicit Animations 默认动画 读书笔记
Implicit Animations 默认动画 读书笔记 Do what I mean, not what I say. Edna Krabappel, The Simpsons Part I ...
- 软件架构期末复习(Struts2+Spring+Hibernate)
Struts2+Spring+Hibernate The Model-ViewController pattern in Struts2 is implemented with the followi ...
随机推荐
- swift - UISlider 的用法
swift的UISlider的用法和oc基本没有区别 1.创建 class SecondViewController: UIViewController { var slider = UISlider ...
- web服务器http.server 【python】
参考博客: http://lxneng.iteye.com/blog/492063 http://www.cnblogs.com/itech/archive/2011/12/31/2308697.ht ...
- osgEarth中的StringUtils头文件中有很多关于字符串的操作
- mac 获取idea&&datagrip激活码
mac 版本的修改如下: 1). Command+Shift+G 2). /private/etc/ 3). 找到hosts文件,用文集编辑器打开 4). 输入0.0.0.0 account.jetb ...
- C++11新特性之八——函数对象function
详细请看<C++ Primer plus>(第六版中文版) http://www.cnblogs.com/lvpengms/archive/2011/02/21/1960078.html ...
- HTTP/2笔记之开篇
前言 本系列基于HTTP/2第17个草案文档,地址就是:https://tools.ietf.org/html/draft-ietf-httpbis-http2-17. HTTP/2规范已经通过发布批 ...
- VScode之JavaScript Snippet Pack
一个片段包 使用例如: cl 回车或者tab键,就可以完整的打出console.log("") 还有很多快捷功能: 参考: https://marketplace.visualst ...
- hibernate实现有两种配置,xml配置与注释配置。<转>
<注意:在配置时hibernate的下载的版本一定确保正确,因为不同版本导入的jar包可能不一样,所以会导致出现一些错误> hibernate实现有两种配置,xml配置与注释配置. (1) ...
- Python老王视频习题答案
基础篇2:一切变量都是数据对象的引用sys.getrefcount('test') 查看引用计数变量命名不能以数字开头编码:ascii.unicode.utf-81.阅读str对象的help文档,并解 ...
- WCF(四) 深入契约
服务契约中的请求-响应操作 1.请求-响应模式 [OperationContract]//1默认就是 请求-相应 Requst- Replay DateTime GetDateTime(); [Ope ...