Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: navbar.nativeElement.append is not a function in Angular Univeral

Hosboss pro asked 6 years ago


We use the PRO version together with Angular Universal (Express Framework). When delivering our app, the following error message is issued by the server: ERROR TypeError: l.navbar.nativeElement.append is not a function
It's the same problem as this :
https://github.com/mdbootstrap/Angular-Bootstrap-with-Material-Design/issues/58

Merci de votre aide !

Damian Gemza staff commented 6 years ago

Dear Turki, could you provide me some reproduction steps? We're not fully compatible with Angular Universal, we have this in our plans to the nearest future. Best Regards, Damian

Hosboss pro commented 6 years ago

Hi Damian, I followed the steps of this tutorial: https://medium.com/@evertonrobertoauler/angular-5-universal-with-transfer-state-using-angular-cli-19fe1e1d352c and I get the error message when I run the command node dist/server.js It's very important, even essential, for me I can not use it for my site if SEO is not possible. Thanks, Best Regards

Damian Gemza staff commented 6 years ago

Turki, I've downloaded repo from this tutorial, added MDB to it and pasted sample code from navbar. Then ran this out, and I see no errors there. Could you send me your project without node_modules at d.gemza@mdbootstrap.com ? Best Regards, Damian

Damian Gemza staff answered 6 years ago


Guys, we're ready to official announce, that our MDB Angular is now compatible with Angular Universal (Server-Side Rendering). Feel free to update your project to latest 5.2.3 version and enjoy it! Best Regards, Damian

Damian Gemza staff answered 6 years ago


Dear Turki, Sorry for so much respond time. I've got fix for this problem. Please head into /free/navb ars/navbar.component.ts and: In constructor change type of renderer from Renderer to Renderer2 then find line:
 this.navbar.nativeElement.append(child)
and change it to
this.renderer.appendChild(this.navbar.nativeElement, child);
And now it should works fine. Let me know if there's more problems. Best Regards, Damian  

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: Yes
  • Provided link: Yes
Tags