首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >角度导入和导出常量

角度导入和导出常量
EN

Stack Overflow用户
提问于 2018-02-17 03:53:05
回答 1查看 293关注 0票数 0

我正在做这个教程,我使用的代码或版本似乎有一些问题。

我正在尝试导入常量。但是,它找不到常量。数组下有红线:arrGender;、arrOccupation:数组等

代码语言:javascript
运行
复制
//3. import all constants
import {
    Occupations,
    JobTypes,
    Genders,
    Hobbies,
    MartialStatuses,
    ResidentTypes,
    Qualifications
} from './constData';

    export class PersonalInformationComponent implements OnInit {
    // 7a. Define the properties for databinding
    person: Person;
    persons: Array<Person>;
    arrGender: Array;
    arrOccupation: Array<Occupations>;
    arrJobType: Array<JobTypes>;
    arrQualification: Array<Qualifications>;
    arrHobbies: Array<Hobbies>;
    arrMartialStatus: Array<MartialStatuses>;
    arrResidentialType: Array<ResidentTypes>;
    canChange: boolean; 
    canEdit: boolean;
    tableHeaders: Array;

    constructor(private pServ: PersonalInfoService) {
        this.canChange = false;
        this.canEdit = false;
        this.tableHeaders = new Array();
        this.person = new Person();
        this.persons = new Array();
        this.arrGender = new Array();
    }
EN

回答 1

Stack Overflow用户

发布于 2018-02-17 12:44:09

代码语言:javascript
运行
复制
//3. import all constants
import {
    Occupations,
    JobTypes,
    Genders,
    Hobbies,
    MartialStatuses,
    ResidentTypes,
    Qualifications
} from './constData';

export class PersonalInformationComponent implements OnInit {
  // 7a. Define the properties for databinding
  person: Person;
  persons: Array<Person>;
  // You forgot to add the type to the Array here...
  arrGender: Array<Gender>;
  arrOccupation: Array<Occupations>;
  arrJobType: Array<JobTypes>;
  arrQualification: Array<Qualifications>;
  arrHobbies: Array<Hobbies>;
  arrMartialStatus: Array<MartialStatuses>;
  arrResidentialType: Array<ResidentTypes>;
  canChange: boolean; 
  canEdit: boolean;
  // You forgot to add the type to the Array here...
  tableHeaders: Array<string>;

  constructor(private pServ: PersonalInfoService) {
    this.canChange = false;
    this.canEdit = false;
    this.tableHeaders = new Array();
    this.person = new Person();
    this.persons = new Array();
    this.arrGender = new Array();
  }
}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48833922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档