angular - “对象”类型不存在属性“方向”
问题描述
我正在使用带有浮动操作按钮的 Angular 7.x 应用程序,当我执行以下命令以在生产模式下构建时,我在终端中遇到了一些错误。
由于方向和 onToggle 已经存在,我该如何解决这个问题?
src\app\components\calendar\calendar.component.html(202,9): : Property 'direction' does not exist on type 'Object'.
src\app\components\calendar\calendar.component.html(201,9): : Property 'onToggle' does not exist on type 'Object'.
// HTML 组件
// 打字稿组件
//
ngcFloatButtonData: Object = {
direction: 'up',
open:false,
onToggle: function(): void {
this.open = !this.open;
},
};
// HTML
<ngc-float-button
(click)="ngcFloatButtonData.onToggle()"
[direction]="ngcFloatButtonData.direction"
解决方案
在打字稿中,通常定义一个类“exampleclass”(exampleclass.ts),如下所示:
export class exampleclass {
propertyOne: number;
propertyTwo: String;
propertThree: number;
}
还要确保您要在模板中访问的属性具有正确的范围 -> public
推荐阅读
- reactjs - 如何在渲染中使用具有数组 setState 的函数
- html - 我在网站上创建了引导模式。但我无法在 Safari 浏览器中打开模式弹出窗口?
- c++ - 使用 Sapera 拍摄图像并将数据复制到矢量
- javascript - 解构嵌套对象:如何获取父级及其子级值?
- elasticsearch - 更改 Elasticsearch 版本控制
- joomla1.5 - 如何将 flv 视频添加到 joomla mod_custom
- vba - 用VBA从word表中删除列
- angular - Angular 7:来自 API 的显示数据按 HTML 中的 Assending 顺序排序
- oracle-data-integrator - 在 ODI 文件到表加载 .bad 和 .error 文件未创建
- angular - 无法在离子数组中推送值