角度接口即将出现未定义

时间:2018-04-24 17:15:23

标签: angular

我的控件中有一个接口,我用它实例化了:

共享:IShared;

我导入的内容:

从'./../../接口/ i-shared';

导入{IShared}

这是我的界面代码:

import { IAddress } from './i-address';
import { IEmail } from "./i-email";
import { IPhone } from "./i-phone";
import { IBusiness } from './i-business';

export interface IShared {
        owner_id:string;
        card_color:string;
        card_name:string;
        card_type:string;
        card_subtitle:string;
        company:string;
        title:string;
        linkedin:string;
        linkedin_bus:string;
        facebook:string;
        google:string;
        twitter:string;
        pinterest:string;
        emails: IEmail[];
        phones: IPhone[];
        addresses: IAddress[];
        businesses: IBusiness[];

} 

但是,当我尝试将某些东西推到'this.shared.phones'时,我收到错误:

ERROR TypeError: Cannot read property 'phones' of undefined

我在这里做错了什么?

0 个答案:

没有答案