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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -