[Angular 2] @Input Custom public property naming
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的更多相关文章
- angular 的 @Input、@Output 的一个用法
angular 使用 @input.@Output 来进行父子组件之间数据的传递. 如下: 父元素: <child-root parent_value="this is parent ...
- Angular 学习笔记 (Custom Accessor + Mat FormField + Custom select)
custom form control 之前就写过了,这里简单写一下. 创建一个组件实现 ControlValueAccessor 接口 @Component({ providers: [ { pro ...
- [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 ...
- [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 ...
- angular学习input输入框筛选
学习angular,看到 angular-phonecat测试用例,照着教程运行了一遍,对于初学者有点不是很理解angular 帅选代码的意思,于是找教材,参考资料,明白了input筛选原来这么简单. ...
- angular.js input
<!DOCTYPE html> <html ng-app="app"> <head> <meta charset="UTF-8& ...
- [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 ...
- [Angular Tutorial] 11 -Custom Filters
在这一步中您将学到如何创建您自己的展示过滤器. ·在先前的步骤中,细节页面展示“true”或“false”来显示某部电话是否有某项功能.在这一步中,我们将使用自定义的过滤器来将这些个字符串转化成符号: ...
- 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( ...
随机推荐
- 引用类型和原始类型的对比(java)
Java 提供两种不同的类型:引用类型和原始类型(或内置类型).另外,Java 还为每个原始类型提供了封装类(Wrapper). 原始类型 封装类=================boolean Bo ...
- 武汉科技大学ACM :1003: 零起点学算法14——三位数反转
Problem Description 水题 Input 输入1个3位数(题目包含多组测试数据) Output 分离该3位数的百位.十位和个位,反转后输出(每组测试数据一行) Sample Input ...
- apache_fileupload实现文件上传_上传多个文件
1.导包 核心类: DiskFileItemFactory – 设置磁盘空间,保存临时文件.只是一个具类. ServletFileUpload - 文件上传的核心类,此类接收request,并解析r ...
- C++拾遗(五)语句相关
前缀格式与后缀格式 对于表达式:后缀如 i++ 表达式的值仍是 i,在遇到下一个顺序点后再将 i 加1.前缀 ++i 表达式的值就是(i+1),先计算表达式的值,不需要等待 顺序点. 对于类:前缀函数 ...
- C++ Const成员函数
一些成员函数改变对象,一些成员函数不改变对象. 例如: int Point::GetY() { return yVal; } 这个函数被调用时,不改变Point对象,而下面的函数改变Point对象 ...
- html中window对象top 、self 、parent 等属性
window对象用法: http://www.w3school.com.cn/htmldom/dom_obj_window.asp top 属性返回最顶层的先辈窗口. 该属性返回对一个顶级窗口的只读引 ...
- jquery的节点查询
jQuery.parent(expr) //找父元素 jQuery.parents(expr) //找到所有祖先元素,不限于父元素 jQuery.children ...
- C 中typedef 函数指针的使用
类型定义的语法可以归结为一句话:只要在变量定义前面加上typedef,就成了类型定义.这儿的原本应该是变量的东西,就成为了类型. int integer; //整型变量int *pointer ...
- python 3.5 用户登录验证和输入三次密码锁定用户
#!/usr/bin/env python #encoding: utf-8 #登录程序,输入用户和密码输出欢迎信息,输入错误三次锁定用户,不让登录 import sys print (''' 欢迎登 ...
- 关于DDOS攻击中TCP半连接数与FD的关系
TCP最大连接数 在tcp应用中,server事先在某个固定端口监听,client主动发起连接,经过三路握手后建立tcp连接.那么对单机,其最大并发tcp连接数是多少? 理论最大值 在确定最大连接数之 ...