This directive will detach the ChangeDetectorRef
simulating AngularJS one-time-binding.
Hello <ng-template oneTime>{{name}}</ng-template>!
@Directive({
selector: '[oneTime]',
})
export class OneTimeDirective {
constructor(template: TemplateRef<any>, container: ViewContainerRef, zone: NgZone) {
zone.runOutsideAngular(() => {
const view = container.createEmbeddedView(template);
setTimeout(() => view.detach());
})
}
}