I have a client side blog app that shows list of articles when loaded. I want to load the article data from server including the dynamic meta tags of that page for SEO purposes
For example:
- I click on a link: https://www.techstack21.com/article/function-returning-other-functions-in-javascript
Where I want make a GET
request with query string /?url=function-returning-other-functions-in-javascript
and render template from server to client similar to pug
or jade
templating engines.
How do I achieve this in angular 6?
I don’t want to render complete app on server but only for particular urls with query strings as example above
2
Answers
This is not possible with Angular. You may only render pure HTML in template using [innerHTML], but then you can not interract with it the angular way.
The good practice is to communicate with a server (using POST/GET requests…) which will send you back serialised “JSON” data of your articles. Then you can render that unserialised JSON data you received from the server with angular components.
You may want to take a look at REST app. 🙂
You can use Meta Service to update your meta data from your API
online example