Declare an array in TypeScript

后端 未结 5 2036
不思量自难忘°
不思量自难忘° 2020-12-12 13:31

I\'m having trouble either declaring or using a boolean array in Typescript, not sure which is wrong. I get an undefined error. Am I supposed to use JavaScript

5条回答
  •  借酒劲吻你
    2020-12-12 14:10

    Specific type of array in typescript

    export class RegisterFormComponent 
    {
         genders = new Array();   // Use any array supports different kind objects
    
         loadGenders()
         {
            this.genders.push({name: "Male",isoCode: 1});
            this.genders.push({name: "FeMale",isoCode: 2});
         }
    }
    
    type GenderType = { name: string, isoCode: number };    // Specified format
    

提交回复
热议问题