angularjs2 六
来源:互联网 发布:程序员需要看的书 编辑:程序博客网 时间:2024/06/02 07:25
import {Component} from 'angular2/core';import {StudentFormComponent } from './student-form'@Component({ selector: 'appTest', template: '<student-form></student-form>', directives: [StudentFormComponent ]})export class App {}
/** * Created by dell on 2016/9/8. */import {Component} from 'angular2/core';import {NgForm} from 'angular2/common';import { Student} from './student';@Component({ selector: 'student-form', templateUrl: 'app/student-form.html'})export class StudentFormComponent { studentList:Student[] = []; student= new Student('马云', 25, "北京市花神街39号"); get studentInfo() { return JSON.stringify(this.student); } onSubmit(value: Student): void { console.log('you submitted value: ', JSON.stringify(value)); this.studentList.push(value); }}
<h1>This is A Student Data!</h1><p>StudentInfo: {{studentInfo}}</p><div *ngFor="#stu of studentList"> <span>{{stu.name}}</span></div><h1>Student Form</h1><form (ngSubmit)="onSubmit(studentForm.value)" #studentForm="ngForm"> <div > <label>名字</label> <input type="text" required [(ngModel)]="student.name" ngControl="name"> </div> <div> <label>年龄</label> <input type="text" required [(ngModel)]="student.age" ngControl="age"> </div> <div> <label>住址</label> <input type="text" [(ngModel)]="student.address" ngControl="address"> </div> <button type="submit">Submit</button></form>
/** * Created by dell on 2016/9/8. */export class Student{ constructor( public name: string, public age: number, public address?: string ) { }}
0 0
- angularjs2 六
- AngularJS2
- Angularjs2
- angularjs2
- angularjs2 一
- angularjs2 二
- angularjs2 三
- angularjs2 四
- angularjs2 五
- angularjs2 七
- angularjs2 八
- angularjs2 九
- angularjs2 十
- angularjs2 指令
- angularjs2 表单
- AngularJS2 架构
- AngularJS2 表单
- AngularJS2入门
- .Net高性能数值计算库—ILNumerics.Net
- JS方法保存变量
- django模板中获取当前网址,当前用户
- 如何判断storyboard中的view conroller对应哪一个.h .m文件?
- iOS AVPlayer 后台播放问题自动停止问题 防止应用被后台挂起方法
- angularjs2 六
- Spring事务传播机制详解
- SHELL网络爬虫实例剖析
- iPhone6s/iPhone6s Plus苹果ios9怎么上Tumblr联合早报打不开怎么办
- mysql删除
- grub2 u盘引导启动CentOS-7-x86_64-Minimal-1511.iso Fedora-Live-Workstation-x86_64-22-3.iso
- 动画 (不停旋转 | 由内向外扩大缩小 透明度渐变)
- 自定义控件三部曲之绘图篇(七)——Paint之函数大汇总
- java 大排序