I have an open source project that does this in an HTML Widget: GitHub - fmr-llc/jive-menu
This allows you to creae a document with a bullet list defining your menu options, and then it will generate the code to go into an HTML Widget to create the menu. You can use that if you do not want to re-create your own, or you can look at the code for reference to see I put the menu together.
Thanks for sharing this. I have created the menu using Angular js. But the major issue I am facing is to hide widgets from the links. I have scenarios in which on one link I need some widget and on the other I don't want the same widget. Is there any way to achieve this. As I am not clear if this is possible or not.