Я сделал обновление с Angular 8 до Angular 9, при запуске приложения отображается сообщение об ошибке:
error NG8002: Can't bind to 'text' since it isn't a known property of 'app-custom-message'.
1. If 'app-custom-message' is an Angular component and it has 'text' input, then verify that
it is part of this module.
У меня не было этой ошибки раньше.
Код выглядит следующим образом:
Page.component.ts
<app-custom-message [icon]='"icon.png"' [text]="'the message'"><app-custom-message>
<app-custom-footer></app-custom-footer>
Ошибка отображается только в пользовательском сообщении, я думал, что это может быть потому, что CUSTOM-MESSAGE имеет свойства, поэтому возьмите прочь свойства и ошибка все еще показывает, странная вещь, что она не отображается в custom-footer.
Custom-Message.ts
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-custom-message',
templateUrl: './message.component.html',
styleUrls: ['./message.component.scss']
})
export class MessageComponent implements OnInit {
@Input() 'text';
@Input() 'url' = null;
@Input() 'icon' = null;
closed = false;
constructor() { }
ngOnInit() { }
}
Я использую отложенную загрузку, и компоненты custom-message и custom-footer находятся в общей папке за пределами домена pageModule, структура выглядит так:
-PageFolder
--PageComponent
--PageModule
-Shared
--CustomMessage
--CustomFooter
Приложение все еще работает, и ошибка беспокоит меня, я знаю, что решение должен импортировать CUSTOM_ELEMENTS_SCHEMA в PageModule, но это предотвращает обнаружение ошибок в будущем при неправильном использовании имени компонента.