[Angular 2] Using ng-model for two-way binding
Angular for Using model two NG Binding way
2023-09-14 09:00:54 时间
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); } }
相关文章
- 从 Angular Route 中提前获取数据
- angular面试题及答案_angular面试
- angular基础面试题_java web面试题
- angular 路由懒加载_angular路由
- 使用 Angular Universal 进行服务器端渲染避免 window is not defined 的错误消息
- Angular forRoot 方法的使用场合介绍
- Angular 应用如何回退到之前曾经浏览过的页面
- 使用 Angular HTTP_INTERCEPTOR 拦截器来记录超时请求的一些思考
- Angular 项目中 angular.json builder 字段的可选项介绍
- Angular 服务器端渲染场景里,服务器端和客户端渲染出的 HTML 源代码有可能不完全一致
- ORA-14755: Invalid partition specification for FOR VALUES clause. ORACLE 报错 故障修复 远程处理
- 循环Linux中使用For循环的正确方式(linux里的for)
- 使用Linux中的For循环实现简单程序(linux的for循环)
- 进程探索Linux中For循环进程管理(linux中for)
- MySQL存储过程中使用FOR循环的实现(mysql存储过程for循环)
- 循环使用Oracle数组实现For循环(oracle数组for)
- Linux下如何优雅地使用For循环(linux下for循环)