@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的更多相关文章

  1. [Angular 2] Passing data to components with 'properties'

    Besides @Input(), we can also use properties on the @Component, to pass the data. import {Component, ...

  2. [Angular 2] Passing Observables into Components with Async Pipe

    The components inside of your container components can easily accept Observables. You simply define ...

  3. angular-ui-router state.go not passing data to $stateParams

    app.js中定义了一个state如下,url接收一个id参数 $stateProvider.state("page.details", { url: "/details ...

  4. 问题-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 ...

  5. Windows 的 Oracle Data Access Components (ODAC)

     下载 x64bit https://www.oracle.com/technetwork/cn/database/windows/downloads/index.html 适用于 Windows 的 ...

  6. WIN7系统 64位出现 Net Framework 数据提供程序要求 Microsoft Data Access Components(MDAC).

    WIN7系统 64位出现  Net Framework 数据提供程序要求 Microsoft Data Access Components(MDAC).请安装 Microsoft Data Acces ...

  7. [转]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 ...

  8. [mjpeg @ ...] unable to decode APP fields: Invalid data found when processing input

    通过FFmpeg打开自己笔记本摄像头(HP Wide Vision HD Camera)操作时遇到如下错误: [mjpeg @ 0000029be7cbd000] unable to decode A ...

  9. [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 ...

随机推荐

  1. Java学习----集合框架总结

    集合框架总结: Collection接口: Set接口: HashSet//对象必须实现hashCode方法,元素没有顺序呢,效率比LinkedHashSet高 LinkedHashSet//是Has ...

  2. c# winfrom 委托实现窗体相互传值

    利用委托轻松实现,子窗体向父窗体传值. 子窗体实现代码: //声明委托 public delegate void MyDelMsg(string msg); //定义一个委托变量 public MyD ...

  3. Apache配置域名

    Apache配置域名 在WIN下安装APACHE配置虚拟目录和UNIN下基本是一样的就是修改httpd.conf1:单个IP对应单个域名例如:www.phpunion.com对应192.168.1.1 ...

  4. POJ2524-宗教问题-并查集-ACM

    太难的搞不过,只能来写简单的了 POJ2524 无所不在的宗教 世界上宗教何其多.假设你对自己学校的学生总共有多少种宗教信仰很感兴趣.学校有n个学生,但是你不能直接问学生的信仰,不然他会感到很不舒服的 ...

  5. 关于Redis的知识汇总[转]

    1. Overview 1.1 资料 <The Little Redis Book> ,最好的入门小册子,可以先于一切文档之前看,免费. 作者Antirez的博客,Antirez维护的Re ...

  6. Why is 0[0] syntactically valid in javascript?

    Why is 0[0] syntactically valid in javascript? 原文链接 偶然在一篇帖子中看到了这个问题,所以打算记录一下. var a = 0[0]; console. ...

  7. Python Tutorial 学习(十)-- Brief Tour of the Standard Library

    10.1. Operating System Interface os库 import os os.getcwd() # Return the current working directory 'C ...

  8. gridview checkbox从服务器端和客户端两个方面实现全选和反选

    GridView中的checkbox的全选和反选在很多的地方都是要求实现的,所以下面就从服务器端和客户端两个方面实现了checkbox的选择,感兴趣的朋友可以了解下,希望本文对你有所帮助 GridVi ...

  9. 【转载】之 破解 (【原创】Xenocode Postbuild 2009 加壳破解 (不断更新中...))

    声明 本文转载,感谢原作者dotNetSafe分享 [原创]Xenocode Postbuild 2009 加壳破解 (不断更新中...) http://bbs.pediy.com/showthrea ...

  10. hbase 0.96 单机伪分布式配置文件及遇到的问题 find命令

    http://www.apache.org/dyn/closer.cgi/hbase/ 国外的站点下载速度慢,可以考虑国内的镜像网站~ 前面已经部署好了hadoop2.2.0单机伪分布式.必须先安装h ...