angular scroll to element in another component
This will be described in details next. I want to use a click event. I'm looking at building elearning which has sections hidden until you click the continue button, then it scrolls down to the next section. Help Request. Not the answer you're looking for? Button Let's create a button that will call a fake backend. The main app component I set like this: As you can see i put an id on each component so i could identify it when trying to scroll. Self taught web developer with more than 10 years of experience in angular, javascript, node.js and more CEO & CTO of Bricks, the agile collaboration platform for architecture & construction. SO question if someone can help I'll upvote for sweet sweet SO points: http://stackoverflow.com/questions/39515060/from-one-component-trigger-scroll-to-top-of-element-in-another-component, It might have to do with where you are calling the function. Edit: I see comments stating that this no longer works due to the element being undefined. const routerOptions: ExtraOptions = { GitHub Nolanus / ngx-page-scroll Public Notifications Fork 107 Star 470 Issues 6 Pull requests 19 Actions Projects Wiki Security Insights New issue How to scroll to a component from another component? Does a summoned creature play immediately after being summoned by a ready action? 1 Answer Sorted by: 20 You can do that with plain javascript using .scrollIntoView (): toTop () { document.getElementById ("content").scrollIntoView (); } Note: you don't need event. The scrollable view is the div.mat-sidenav-content the sidenav module introduces while creating itself. What is the correct way to screw wall and ceiling drywalls? If the element is in a different component you can reference it several different ways as seen in this question. The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie We've added a "Necessary cookies only" option to the cookie consent popup. setting a class for the parent of a active router link, Angular 2+, Style button of dropdown toggle depending on RouterLinkActive of nav-link, Movie with vikings/warriors fighting an alien that looks like a wolf with tentacles. Apply this on elements you want to scroll : To subscribe to this RSS feed, copy and paste this URL into your RSS reader. I am also using Angular-material and using the sidenav component. Is there a single-word adjective for "having exceptionally strong moral principles"? Its just a bad example with bad logic using jQuery which is not what was asked. Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Share Improve this answer Follow edited Aug 21, 2018 at 13:03 answered Jul 6, 2018 at 14:51 Jeffrey Roosendaal 6,706 8 37 54 Is it correct to use "the" before "materials used in making buildings are"? This is what my app.component.html looks like at the moment: the