Open alsoicode opened 4 years ago
Any update on this? I'm also experiencing the same issue trying to upgrade a project to Angular 9.x. Thanks.
@orizens I looked into the issue and it appears to be related to: https://angular.io/guide/migration-dynamic-flag
As I currently see it, there are two options to resolve this: migrate to Angular 9 and make suggestionTplRef
static or move the renderTemplate()
function to the ngAfterViewInit()
hook. Both solutions are outlined below.
Angular 9 migration
@ViewChild('suggestionsTplRef', { read: TemplateRef, static: true })
suggestionsTplRef!: TemplateRef<any>;
with ngAfterViewInit()
renderTemplate() {
const embeddedViewRef = this.viewContainer.createEmbeddedView(this.suggestionsTplRef);
// prevents change detection errors
embeddedViewRef.detectChanges();
this.cdr.markForCheck();
}
ngOnInit() {
this.filterEnterEvent(this.keydown$);
this.listenAndSuggest(this.keyup$);
this.navigateWithArrows(this.keydown$);
}
ngAfterViewInit() {
this.renderTemplate();
}
As I've already performed all of the necessary work for the migration on my fork, I'd suggest this approach which should remain backwards compatible as the final build will keep using the old view engine (as recommended by the Angular Dev team).
Please advice and I will make a pull request accordingly.
hi @SamWolfs thanks for your comment. feel free to open a pr.
@SamWolfs
upgrade to ng9 has started within this branch
https://github.com/orizens/ngx-typeahead/tree/feautre/migrate-ng9
npm run build
does not produce the final build yet. you're welcome to contribute
When using Angular 9.0 or above, I receive the following error:
With the following template code: