-
Notifications
You must be signed in to change notification settings - Fork 482
Question: How to use querySelector ? Server says querySelector is not a function #637
Comments
Correct me if I'm wrong, but don't you need to import isBrowser from ng2-universal, and create a conditional where if that's true, then do your querySelector. |
Yes it is a solution, except that I am using universal for seo purpose. I would like to render the meta tags of my html on server side. That's why I am using querySelector and I need it on server side (not in a isBrowser if). |
Oh ok, my bad! You can try using the meta service as is done here: https://github.com/angular/universal-starter/blob/master/src/angular2-meta.ts Let me know if that is able to help you. I'll be starting on this probably later part of this week, so it'd be cool to coordinate! |
Thank you ! It works ! |
No problem dude! Good luck. Also can you close this? :) |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hello !
I am trying to use
document.querySelector
in a service to automatically update all meta tags in a page (it is based on ng2-meta : https://github.com/vinaygopinath/ng2-meta).document
is injected in my service constructor as followThe problem is that the server keeps displaying an exception
What I am doing wrong ? How to use querySelector properly ?
I am using universal v2.1.0-rc.1. According to this repository,
querySelector
is supported by universal.The text was updated successfully, but these errors were encountered: