I tried something like:
<a href="#parallaxdiv">Teste</a>
<div id="parallaxdiv"></div>
I tried something like:
<a href="#parallaxdiv">Teste</a>
<div id="parallaxdiv"></div>
I was able to resolve using:
<a (click)="scroll(target)"
<div #target>Your target</div>
Note that for this to work by using the checked solution, you must have a scroll-named method that receives a parameter. In the scroll (param) case it would be an example signature.
You can use ready-made solutions like SmoothScroll , which also allows you to configure some other features such as example scrolling smoothly and setting the scroll time. It has simple and complete documentation, but anyway follow the example below:
<!-- Script CDN para ancora -->
<script src="https://cdn.jsdelivr.net/gh/cferdinandi/smooth-scroll@15/dist/smooth-scroll.polyfills.min.js"></script><script>letscroll=newSmoothScroll('a[href*="#"]', {
speed: 300,
speedAsDuration: true,
<!-- History -->
updateURL: true, <!-- Update the URL on scroll -->
popstate: true <!-- Animate scrolling with the forward/backward browser buttons (requires updateURL to be true) -->
});
This is only used normally in HTML as you did in the problem description:
<a href="#parallaxdiv">Teste</a>
<div id="parallaxdiv"></div>