Two-way binding still exists in Angular 2 and ng-model makes it simple. The syntax is a combination of the [input] and (output) syntax to represent that the data is being pushed out and pulled in.

import {Component, View, FORM_DIRECTIVES} from "angular2/angular2";
import {TodoService} from "./todoService";
@Component({
selector: 'todo-input'
})
@View({
directives: [FORM_DIRECTIVES],
template: `
<form action="" (ng-submit)="onSubmit()">
<input type="text" [(ng-model)]="todoModule">{{todoModule}}
</form>
`
})
export class TodoInput{
todoModule; constructor(
//@Inject(TodoService) todoService
public todoService:TodoService
){
this.todoService = todoService;
console.log(todoService);
} onSubmit(){
this.todoService.addTodo(this.todoModule);
}
}

最新文章

  1. tornado 学习笔记8 模板以及UI
  2. nyoj998(euler)
  3. angularjs如何在视图渲染结束之后,或者render之后执行指令中的link方法呢?
  4. jquery 小知识点
  5. CentOS6.5 安装JDK1.7详细步骤参考
  6. [ Windows] [ OS ] [ Remote Desktop ] 開啟同一個帳號同時2的連線RDP的方式
  7. 【故障】当Eclipse打不开的时候
  8. 更改 android realtek的系统权限
  9. 如何内网搭建NuGet服务器
  10. 【Java】留下没有基础眼泪的面试题
  11. 【spring源码分析】IOC容器初始化(二)
  12. 『Two 树的直径求解及其运用』
  13. scrollTo不起作用
  14. Java基于opencv—透视变换矫正图像
  15. linux 系统备份和恢复
  16. python之attrgetter函数对对象排序
  17. java中String类型
  18. 推荐几个Windows工具软件: Stickies - 桌面贴
  19. 您的windows许可证即将过期 win10的解决办法
  20. 微信小程序组件 分页菜单点击请求

热门文章

  1. printf 格式化最常用用法
  2. nginx+php,502错误
  3. 『重构--改善既有代码的设计』读书笔记----Self Encapsulate Field
  4. sql server 数据分页显示。
  5. 通过C# 打开一个应用程序
  6. 在Linux终端执行clear或top命令时出现:&#39;xterm&#39;: unknown terminal type
  7. Python 环境
  8. BAE 环境下配置 struts2 + spring + hibernate(SSH)(一)准备
  9. vim技巧:折叠快捷键
  10. gcc将多个静态库链接成一个静态库