[Angular 2] Passing data to components with @Input
@Input allows you to pass data into your controller and templates through html and defining custom properties. This allows you to easily reuse components, such as item renderers, and have them display different values for each instance of the renderer.
todoItemRender.ts
import {Input, Component, View} from "angular2/angular2";
@Component({
selector: 'todo-item-render'
})
@View({
template: `
<div>
<span [content-editable]="todoinput.status === 'started'">{{todoinput.title}}</span>
<button (click)="todoinput.toggle()">Toggle</button>
</div>
`
})
export class TodoItemRender{
@Input() todoinput: TodoModel;
}
todoList.ts
import {Component, View, NgFor} from 'angular2/angular2';
import {TodoService} from './todoService';
import {TodoItemRender} from './todoItemRender'
@Component({
selector: 'todo-list'
})
@View({
directives: [NgFor, TodoItemRender],
template: `
<div>
<todo-item-render
*ng-for="#todo of todoService.todos"
[todoinput]="todo"
>
</todo-item-render>
</div>
`
})
export class TodoList{
constructor(
public todoService:TodoService
){
}
}
[Angular 2] Passing data to components with @Input的更多相关文章
- [Angular 2] Passing data to components with 'properties'
Besides @Input(), we can also use properties on the @Component, to pass the data. import {Component, ...
- [Angular 2] Passing Observables into Components with Async Pipe
The components inside of your container components can easily accept Observables. You simply define ...
- angular-ui-router state.go not passing data to $stateParams
app.js中定义了一个state如下,url接收一个id参数 $stateProvider.state("page.details", { url: "/details ...
- 问题-Error creating object. Please verify that the Microsoft Data Access Components 2.1(or later) have been properly installed.
问题现象:软件在启动时报如下错误信息:Exception Exception in module zhujiangguanjia.exe at 001da37f. Error creating obj ...
- Windows 的 Oracle Data Access Components (ODAC)
下载 x64bit https://www.oracle.com/technetwork/cn/database/windows/downloads/index.html 适用于 Windows 的 ...
- WIN7系统 64位出现 Net Framework 数据提供程序要求 Microsoft Data Access Components(MDAC).
WIN7系统 64位出现 Net Framework 数据提供程序要求 Microsoft Data Access Components(MDAC).请安装 Microsoft Data Acces ...
- [转]Passing data between pages in JQuery Mobile mobile.changePage
本文转自:http://ramkulkarni.com/blog/passing-data-between-pages-in-jquery-mobile/ I am working on a JQue ...
- [mjpeg @ ...] unable to decode APP fields: Invalid data found when processing input
通过FFmpeg打开自己笔记本摄像头(HP Wide Vision HD Camera)操作时遇到如下错误: [mjpeg @ 0000029be7cbd000] unable to decode A ...
- [Angular 2] Passing Template Input Values to Reducers
Angular 2 allows you to pass values from inputs simply by referencing them in the template and passi ...
随机推荐
- 初探grunt.js
package.js { "name": "ttd_v3", "version": "0.1.0", "aut ...
- Bootstrap_表单_按钮
一.多标签支持 一般制作按钮除了使用<button>标签元素之外,还可以使用<input type="submit">和<a>标签等. 同样,在 ...
- CSS3的appearance属性--改变元素的外观
CSS3 appearance 属性 CSS 参考手册 实例 使 div 元素看上去像一个按钮: div { appearance:button; -moz-appearance:button; /* ...
- java枚举小结
如何定义一个枚举类? //定义了4个等级 enum Level{ A,B,C,D } 枚举类的实质: class Level{ public static final Level A = new Le ...
- 2. SharePoint Online 开发,请联系qq512800530。加好备注。(不要发站内信。。。)
///(不要发站内信...) <meta name="keywords" content="SharePoint Online, SP Online, SPO, S ...
- [BZOJ 1257] [CQOI2007] 余数之和sum 【数学】
题目链接:BZOJ - 1257 题目分析 首先, a % b = a - (a/b) * b,那么答案就是 sigma(k % i) = n * k - sigma(k / i) * i ( ...
- Children of the Candy Corn
poj3083:http://poj.org/problem?id=3083 题意:给你一个迷宫,然后给你一个起点和终点,现在给你种规则,一种是先向左,无法向左则向前,无法向前则向右,否则则向后,另外 ...
- hdu 5150 Sit sit sit
http://acm.hdu.edu.cn/showproblem.php?pid=5151 直接判断是不是素数,然后再注意1就行. #include <cstdio> #include ...
- IHS怎么通过80端口连接WAS——<转>
IHS如何通过80端口连接WAS? 经常看到有朋友问这个问题,所以简单总结一下基本步骤: IHS和WAS之间是通过Plugin来实现的,一般的Plugins和IHS安装在同一物理机器上,WAS安装 ...
- 24篇Delphi文件操作文章
http://www.cnblogs.com/keyvip/category/268043.html