[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 ...
随机推荐
- golang bufio writer,reader 缓存规则
读,写,缓冲区可以杜绝频繁的读,写动作1.写缓存,如果一次write的长度大于buffer长度那么久发送当前缓冲区的内容并且发送要写入的内容,就是不在缓存了.如果发送的内容小于buffer长度,就按缓 ...
- H5相关
对于容器元素,尤其在做移动端产品时候,我们很自然会让其居中定位: .container { position: absolute; left: %; top: %; transform: transl ...
- php函数——『解析 xml数据』
<?php //该文件是 //$raw_post_data = file_get_contents('php://input'); //file_put_contents('a.txt', $r ...
- Python学习 - 使用BeautifulSoup来解析网页一:基础入门
写技术博客主要就是总结和交流的,如果文章用错,请指正啊! 以前一直在使用SGMLParser,这个太费时间和精力了,现在为了毕业设计,改用BeautifulSoup来实现HTML页面的解析工作的. 一 ...
- Linux学习2
第三讲Linux常用命令04 压缩:gzip: 1.只能压缩文件,不能压缩目录 2.不保留源文件 解压缩:gunzip gzip -d ------------------------------ ...
- 学会爱上iOS自动布局(Auto Layout) - 剑尖
本文翻译自Yari Dareglia的LEARN TO LOVE AUTO LAYOUT文章先生们,女士们,让我们以正确的心态开始本教程吧:自动布局就是简单!我花了一段时间来掌握自动布局是如何工作的, ...
- NandFlash
一.概述 1.NandFlash NAND结构能提供极高的单元密度,可以达到高存储密度,比如能达到256M,并且写入和擦除的速度也很快.应用NAND的困难在于flash的管理需要特殊的系统接口. 2. ...
- bzoj1038: [ZJOI2008]瞭望塔
Description 致力于建设全国示范和谐小村庄的H村村长dadzhi,决定在村中建立一个瞭望塔,以此加强村中的治安.我们将H村抽象为一维的轮廓.如下图所示 我们可以用一条山的上方轮廓折线(x1, ...
- SequoiaDB 架构指南
1 简介 SequoiaDB(巨杉数据库)是一款分布式非关系型文档数据库,可以被用来存取海量非关系型的数据,其底层主要基于分布式,高可用,高性能与动态数据类型设计,与当前主流分布式计算框架 Hadoo ...
- Javascript 注意点
prototype有助于减少function的冲突. 闭包有助于避免全部变量. this, prototype有助于实例化多个对象. 函数 函数表达式