title: How can I scroll to an anchor in my angular page
body: <p>I want to create anchor in my angular page but it doesn't work and I don't know why.</p>
  
  <p>My html component :</p>
  
  <pre><code>&lt;h1 id="choose_package"&gt;Step 1 : choose a package&lt;/h1&gt;
  &lt;div&gt;Some elements&lt;/div&gt;
  &lt;a [href]="choose_package"&gt;test&lt;/a&gt;
  </code></pre>
  
  <p>But it return me null and go to 404 page.</p>
  
  <p>Edit (now I can scroll but it's not done little by little):</p>
  
  <pre><code>this.router.events.pipe(filter(e =&gt; e instanceof Scroll)).subscribe((e: any) =&gt; {
      if (e.position) {
        this.viewportScroller.scrollToPosition(e.position);
      } else if (e.anchor) {
        this.viewportScroller.scrollToAnchor(e.anchor);
      } else {
        this.viewportScroller.scrollToPosition([0, 0]);
      }
    ;
  });
  </code></pre>