角度材料 - 词缀

lma*_*occ 13 javascript typescript angular-material angular

我正在使用角度为4的角度材料2.0.0-beta.12.

我想在角料网站上实现一种叫做"词缀〜"的东西

我需要构建像这样的图像:

在此输入图像描述

在滚动时,如果在页面上看到内容,这些项目将"活动".每个项目也都有一个锚点.

谁知道一个简单而干净的方法呢?

提前谢谢您的时间.

fer*_*cho 1

如果您需要从头开始创建,可以按照教程进行操作:

https://oliverveits.wordpress.com/2017/07/18/angular-4-automatic-table-of-contents/

它解释了如何创建两级自动目录。您可以通过执行以下操作来克隆代码:

# git clone https://github.com/oveits/ng-universal-demo
# cd ng-universal-demo
# git checkout 8ca27d5   # to be sure you are working with exact same that has been created in this blog
Run Code Online (Sandbox Code Playgroud)

您也可以使用材质角度目录https://github.com/angular/material.angular.io/blob/b029f9108d4c89ce4dd75cffaaf4ea9d365dcc70/src/app/shared/table-of-contents