angular - Angular 接口出现未定义
问题描述
我在我的控件中有一个接口,我用它来实例化:
共享:IShared;
我进口的:
从'./../../interfaces/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
我在这里做错了什么?
解决方案
推荐阅读
- linux - 我需要扫描文件中的特殊字符
- angular - 如何使用角度中的另一个变量分配一个严格的数据类型变量值?
- elasticsearch - 在 elasticsearch 中搜索查询,返回匹配 value_1 或 value_2 但不同时匹配的结果
- python - 我试图运行这段代码并不断给我这个错误结果.push(3) AttributeError: 'Stack' object has no attribute 'push'
- arrays - 当这些行与列表中的所有值匹配时,从 Python 中的 DF 中选择行
- python - 如何使代码不可读但可执行?
- c - C - 用信号量同步多个孩子的优雅方式
- android - Android下系统亮度的困惑
- python - 无法获得秘密圣诞老人代码来记住分配的名称
- vmware-fusion - VMware Fusion 12 共享文件夹