import { Component, OnInit } from '@angular/core';


interface Student{
  name:string
  age:number
  idcard?:string
}

@Component({
  selector: 'app-tsdatatype',
  templateUrl: './tsdatatype.page.html',
  styleUrls: ['./tsdatatype.page.scss'],
})
export class TsdatatypePage implements OnInit {

  title:string = "TS数据类型与NG模板指令"
  likeCount:number = 99
  isCollection:boolean = false
  now:Date = new Date();
  dataTypeList:Array<string> = ["string","number","boolean"]
  dataTypeList2:string[] = []

  // 接口：Student
  student:Student = {
    name:"XiaoMing",
    age:18,
    idcard:"322xxxxxxxxxxxxxx"
  }
  studentList:Array<Student> = []
  

  constructor() { 
    // 接口数组：Array<Student>
    let studentList:Array<Student> = []
    // 必填属性
    let xiaoming = {name:"XiaoMing",age:18,idcard:"322*0000",lev:3}
    // 可选属性
    let xiaoli = {name:"XiaoLi",age:17}
    studentList.push(xiaoming)
    studentList.push(xiaoli)
    this.studentList = studentList
    // 未定义变量的预先取值
    setTimeout(() => {
      this.studentList.push({name:"小王",age:19})
    }, 2000);

  }

  ngOnInit() {
  }

}
