在具有@input属性的组件声明Angular模块中要导入什么?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在具有@input属性的组件声明Angular模块中要导入什么?相关的知识,希望对你有一定的参考价值。
Angular 8.X
[之前,我将所有组件导入并在app.module.ts中声明现在我正在为每个功能制作模块但是对于声明@input的组件,我得到了错误:
**Uncaught Error: Template parse errors:
Can't bind to 'device' since it isn't a known property of 'igwan-device-detail'.
1. If 'igwan-device-detail' is an Angular component and it has 'device' input, then verify that it is part of this module.
2. If 'igwan-device-detail' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.**
我的组件:
import Component, OnInit, Input from '@angular/core';
@Component(
selector: 'igwan-device-detail',
templateUrl: './device-detail.component.html',
styleUrls: ['./device-detail.component.scss']
)
export class DeviceDetailComponent implements OnInit
@Input() device: any;
@Input() alert: any;
constructor()
ngOnInit()
我的模块:
import NgModule from '@angular/core';
import FormsModule, ReactiveFormsModule from '@angular/forms';
import CommonModule from '@angular/common';
import MatTableModule from '@angular/material';
import MatPaginatorModule from '@angular/material/paginator';
import ParkManagementComponent from './park-management/park-management.component';
import DeviceDetailComponent from './device-detail/device-detail.component';
@NgModule(
declarations: [DeviceDetailComponent],
imports: [FormsModule, ReactiveFormsModule, CommonModule, MatTableModule, MatPaginatorModule],
exports: [DeviceDetailComponent]
)
export class DeviceSearchModule
您知道还需要导入什么吗?
答案
无法绑定到'设备',因为它不是'igwan-device-detail'的已知属性。
以上是关于在具有@input属性的组件声明Angular模块中要导入什么?的主要内容,如果未能解决你的问题,请参考以下文章
Angular @Input getter/setter 和非原始值
来自另一个模块的组件上的 Angular 指令输入会导致错误