In my Angular project, I am working with typescript and trying to assign the IInfoPage interface to some data.
export interface IInfoPage {
href: string;
icon: string;
routing: boolean;
order: number;
styleType: string;
}
public pageData: IInfoPage;
this.configService.PageData.subscribe((res) => {
this.pageData = res.SubMenu.find(data => location.pathname.includes('path'));
})
However, when I try to access this.pageData, it alerts me with an error message:
Type 'ISubMenuType | undefined' is not assignable to type 'IInfoPageSubData'. Type 'undefined' is not assignable to type 'IInfoPageSubData'.
Does anyone have any ideas on how to resolve this issue?