TodoList.ts:

@Component({
selector: 'todo-list',
directives: [TodoItemRenderer],
template: `
<ul>
<li *ngFor="#todo of todoService.todos">
<todo-item-renderer [todo]="todo"></todo-item-renderer>
</li> </ul>
`
})

TodoItemRender.ts:

import {Component, Input} from 'angular2/core';
@Component({
selector: 'todo-item-renderer',
template: `
<div>
<span [hidden]="todo.status == 'completed'"
[contentEditable]="todo.isEdit">{{todo.title}}</span>
<button (click)="todo.toggle()">Toggle</button>
<button (click)="todo.edit()">Edit</button>
</div>
`
}) export class TodoItemRenderer{
@Input() todo
}

Current we pass [todo] to the itemRender from List, we actually can give @Input('name'):

TodoList.ts:

 <todo-item-renderer [todoItem]="todo"></todo-item-renderer>

TodoItemRender.ts:

@Input('todoItem') todo

Ref: Link

[Angular 2] @Input Custom public property naming的更多相关文章

  1. angular 的 @Input、@Output 的一个用法

    angular 使用 @input.@Output 来进行父子组件之间数据的传递. 如下: 父元素: <child-root parent_value="this is parent ...

  2. Angular 学习笔记 (Custom Accessor + Mat FormField + Custom select)

    custom form control 之前就写过了,这里简单写一下. 创建一个组件实现 ControlValueAccessor 接口 @Component({ providers: [ { pro ...

  3. [Angular] Create a custom validator for reactive forms in Angular

    Also check: directive for form validation User input validation is a core part of creating proper HT ...

  4. [Angular] Create a custom validator for template driven forms in Angular

    User input validation is a core part of creating proper HTML forms. Form validators not only help yo ...

  5. angular学习input输入框筛选

    学习angular,看到 angular-phonecat测试用例,照着教程运行了一遍,对于初学者有点不是很理解angular 帅选代码的意思,于是找教材,参考资料,明白了input筛选原来这么简单. ...

  6. angular.js input

    <!DOCTYPE html> <html ng-app="app"> <head> <meta charset="UTF-8& ...

  7. [Angular 2] @Input & @Output Event with ref

    The application is simple, to build a color picker: When click the rect box, it will check the color ...

  8. [Angular Tutorial] 11 -Custom Filters

    在这一步中您将学到如何创建您自己的展示过滤器. ·在先前的步骤中,细节页面展示“true”或“false”来显示某部电话是否有某项功能.在这一步中,我们将使用自定义的过滤器来将这些个字符串转化成符号: ...

  9. ng-packagr 打包报错 Public property X of exported class has or is using name 'Observable' from external module “/rxjs/internal/Observable” but cannot be named

    old import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; @Injectable( ...

随机推荐

  1. 基于脚本的动画的计时控制(“requestAnimationFrame”)(转)

    requestAnimationFrame 方法的支持,该方法通过在系统准备好绘制动画帧时调用该帧,从而为创建动画网页提供了一种更平滑更高效的方法.在此 API 之前,使用 setTimeout 和  ...

  2. (转)JQuery中$.ajax()方法参数详解

    url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如put和 ...

  3. a标签增加onclick事件提示未定义function

    项目使用的是ext框架,版本是ext4.2 出现的问题代码如下: renderer : function(value){ var html = "<a href=\"java ...

  4. Struts2 文件下载

    使用Struts2做一个简单的文件下载. 首先,导包,写配置文件就不说了. 进入主题. 文件下载操作类:FileDownload.java import java.io.InputStream; im ...

  5. javascript中的事件问题

    事件的类型: (1)鼠标事件:   click用户点击鼠标时发生,当用户的焦点在按钮上,并按了回车键,同样会触发这个事件 dbclick 用户双击鼠标左键时发生    mouseover 鼠标移出某个 ...

  6. memcache配置与使用

    php100:73:MemCached高级缓存配置 Memcache相关介绍: memcache 是一个高性能的分布式的内存对象缓存系统,它能够存储各种各样的的数据,包括图片,视频,文件等等.缓存功能 ...

  7. php urlencode()函数URL编码转换实例解析

    URLEncode:是对网页url所包含中文字符的一种编码转化方式,URLEncode有两种常见方式,一种是基于GB2312的 Encode(Baidu.Yisou等搜索引擎使用),另一种是基于UTF ...

  8. 创建Windows服务简单流程

    1.首先打开VS2010(或者其他版本),创建Windows服务项目 2.创建完成后切换到代码视图,代码中默认有OnStart和OnStop方法执行服务开启和服务停止执行的操作,下面代码是详细解释: ...

  9. C 简单单元测试框架

    大约2年前,仿照GTEST写了个简单的C++单元测试框架. http://www.cnblogs.com/imlgc/archive/2012/02/09/2344506.html 后来用C写后台程序 ...

  10. file_get_content、fsockopen和curl之间的优缺点

    file_get_content 优点:在抓取单个文件上,效率很高,返回没有头信息的文件. 缺点:在抓取远程文件时,和fopen一样容易出错.在抓取多个跨域文件时,未对DNS进行缓存,所以效率上不不高 ...