angular - How to programmatically change x-position attribute of md-menu? -


md-menu has x-position = "before | after" attribute. want change attribute dynamically. far, i've tried

<md-menu [attr.x-position]="islefttorightlanguage()? 'after': 'before'" ... > 

that didn't work (no errors). tried without square brackets got me mdmenuinvalidpositionx error in browser console.

<md-menu x-position="islefttorightlanguage()? 'after': 'before'" ... > 

ps: islefttorightlanguage() method in component returns boolean.

you shoud using mdmenutriggerfor property below

<button md-icon-button [mdmenutriggerfor]="menu" (click)="clicked($event)">   <md-icon>more_vert</md-icon> </button> <md-menu #menu="mdmenu">   <button md-menu-item>   <span>redial</span>   </button>   <button md-menu-item disabled>   <span>check voicemail</span>   </button>   <button md-menu-item>   <span>disable alerts</span>   </button> </md-menu> 

alternatively can use positionx , positiony , handle event position below,

clicked(event){      console.log(event);   } 

you should using event.screenx , event.screeny clicked x , y positions

live demo


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -