How to implement dropdown with dynamic levels in Angular

I have a data structure like:

var menu_data=[
    {'name':'A', 'next':[{'name':'AA', 
                          'next':[{'name':'AAA', 
                                   'next': []}]}] },
    {'name':'B', 'next':[{'name':'BA', 'next':[]},
                         {'name':'BB', 'next':[]}
                        ]
    }
]

So the dropdown has following levels:

A->AA->AAA;

B->BA

 ->BB

The setup of the dropdown(menu) is purely driven by the menu_data, so the levels are not pre-determined. How can this be implemented?