简体   繁体   中英

Get DOM element from service in Angular 4

I have root component in my hierarchy, called "root-app". Also i have router and few components, which loaded by this router. Than i have a service, which control page navigation. I need to get one element

<img #animationDetails src='..' alt=''>

from each component after it is loaded, from this service. How i can get element from service after it is loaded by router.

You cant get DOM elemnt form service. I wonder why would you even need to get the element from service. You can manipulate the DOM when services return the observables inside component callbacks. Take a look at this question on how to perform DOM manipulation from components in Angular: How to perform DOM manipulation in Angular components

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM