I use Angular Material Portal to move element in another place.
I use cdkPortal
and cdkPortalOutlet
.
I don't understand why angular throw expression changed in this super simple example
import { Component, ViewChild } from '@angular/core';
import { CdkPortal } from '@angular/cdk/portal';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
@ViewChild(CdkPortal, { static: false }) portal: CdkPortal
}
Check code here: https://stackblitz.com/edit/angular-f6sb21
open console to see error:
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'portal: undefined'. Current value: 'portal: [object Object]'