Groups
Groups

Angular Dynamic Menu using Material design lite

26 views
Skip to first unread message

pedro costa

unread,
May 25, 2019, 12:11:15 PM5/25/19
to Angular and AngularJS discussion

I want to create a dynamic menu, the data is get from database for instance. Here is the StackBlitz project.


In the dynamic-menu.component.html in the StackBlitz project there are the dynamic solution and the static solution(that is commented).

 

The static solution should be how the dynamic solution will be rendered after executes.

If i just run with the static solution(uncomment and commented the dynamic) everything runs as expected, but if i try with the dynamic solution the menu does not work as expected (the main buttons stays on top of each other and the submenus do not display and work properly).

Is this related with how ng-template affect the CSS styles ?

Looking through Chrome developer tools i am able to see that the class="mat-menu-item ng-star-inserted" attribute in the dynamic version is added to the button for instance and this does not happen in the static version. I have try everything but i can not get it why is this happening. And how can i fix this. I am new to Angular but i want really understands how the frameworks works


Thanks in advance

Best regards

pedro costa

unread,
May 25, 2019, 12:11:15 PM5/25/19
to Angular and AngularJS discussion
0

I want to create a dynamic menu, one that is get from database. Here is the StackBlitz project.


In the dynamic-menu.component.html of the StackBlitz project are the dynamic solution and commented is the static solution. 

The static solution should be how the dynamic solution will be rendered after executes.

If i just run with the static solution everything runs as expected(just uncomment the static code and comment the dynamic code), but if i try with the dynamic solution the menu does not work as expected.The ui stays completely disorganize and the sub menus do not work well. 

Reply all
Reply to author
Forward
0 new messages
Search
Clear search
Close search
Google apps
Main menu