javascript - Angular - How can I access an outside app element? -


i'm using angular 4.3.1.

suppose have index.html file :

<!doctype html> <html>   <head>     <base href="." />      ...      ...   </head>    <body>     <my-app>     loading...   </my-app>   </body> </html> 

an app "domain" starting <my-app> elements , inner elements.

but if want access <head> element , set 1 of it's attribute value ?

something :

  <head [myval]="myobjectval"> 

sure can access dom via document.queryselector() , wonder if there's better way ( angular way maybe?)

question:

suppose have service (@injectable) , has object , how can set <head [myval]="myobjectval"> in angular way ?

plunker

angular doesn't support binding elements outside root element.

you can use plain ts/js like

document.queryselector('head')... 

there meta service allows set meta tags.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -