我从https://angular.io/guide/elements#example-a-popup-service下载 Angular Element 演示
并在 html 中使用自定义元素并给出一条消息,但它会在控制台中显示 expressionchangedafterithasbeencheckederror。
我只是像这样更改了 AppComponet html 代码
@Component({
selector: 'app-root',
template: `
<input #input value="Message">
<popup-element [message]="'aa'"></popup-element>
`,
})
export class AppComponent implements OnInit{
constructor(injector: Injector, public popup: PopupService) {
// Convert `PopupComponent` to a custom element.
const PopupElement = createCustomElement(PopupComponent, {injector});
// Register the custom element with the browser.
customElements.define('popup-element', PopupElement);
}
}
它会在页面中显示“aa”消息,并且浏览器控制台中存在错误。
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'null: undefined'. Current value: 'null: aa'.
at viewDebugError (core.js:25716)
at expressionChangedAfterItHasBeenCheckedError (core.js:25693)
at checkBindingNoChanges (core.js:25868)
at checkNoChangesNodeInline (core.js:30037)
at checkNoChangesNode (core.js:30010)
at debugCheckNoChangesNode (core.js:30917)
at debugCheckRenderNodeFn (core.js:30849)
at Object.eval [as updateRenderer] (PopupComponent.html:2)
at Object.debugUpdateRenderer [as updateRenderer] (core.js:30834)
at checkNoChangesView (core.js:29845)
我怎么解决这个问题?