How to check if element has class with AngularJS?

for those (including me) who could not get their head around Angular’s documentation, here is an example which worked for me: angular.element(myElement).hasClass(‘my-class’); angular.element(myElement).addClass(‘new-class’); angular.element(myElement).removeClass(‘old-class’); hope this help someone …

jQuery add class .active on menu

Click here for a solution in jsFiddle What you need is you need to get window.location.pathname as mentioned and then create regexp from it and test it against navigation hrefs. $(function(){ var url = window.location.pathname, urlRegExp = new RegExp(url.replace(/\/$/,”) + “$”); // create regexp to match current url pathname and remove trailing slash if present … Read more

How to create a JButton with a menu?

This is way harder in Swing than it needs to be. So instead of pointing you to tutorials I’ve created a fully working example. import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class ToolbarDemo { public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setPreferredSize(new Dimension(600, 400)); final JToolBar … Read more

Same option menu in all Activities in Android

Create a Class (say BaseActivity) that extends Activity, and override onCreateOptionsMenu and onOptionsItemSelected functions. public class BaseActivity extends Activity { // Activity code here @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item: // do what you want … Read more

Dynamic nested Material menu from json object in Angular 5

The following structure should work for you: <button mat-button [matMenuTriggerFor]=”main_menu”>My menu</button> <mat-menu #main_menu=”matMenu”> <ng-container *ngFor=”let mainItem of objectKeys(my_menu)”> <button mat-menu-item [matMenuTriggerFor]=”sub_menu”>{{ mainItem }}</button> <mat-menu #sub_menu=”matMenu”> <button *ngFor=”let subItem of my_menu[mainItem]” mat-menu-item>{{ subItem }}</button> </mat-menu> </ng-container> </mat-menu> Since I placed sub_menu inside the embedded template (*ngFor) we can use the same name for template reference variable(#sub_menu). … Read more

How to add line divider for menu item Android

Make sure to call MenuCompat.setGroupDividerEnabled(menu, true); when you inflate your menu, otherwise groups will not be separated by divider! Example: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_activity_main, menu); MenuCompat.setGroupDividerEnabled(menu, true); return true; } And make sure to have different groups in your menu xml, e.g.: <menu> <group android:id=”@+id/sorting” > <item android:id=”@+id/action_sorting_new_old” android:title=”@string/action_sorting_new_old”/> <item android:id=”@+id/action_sorting_a_z” android:title=”@string/action_sorting_a_z”/> … Read more

What is a WAI-ARIA compliant implementation for navigation bar/menu

A possible implementation would be: HTML structure: <div> <!– Outer wrapper –> <ul> <!– Main navigation bar container –> <li> <!– First-level item without submenu –> <a> <!– Destination URL –> </a> </li> <li> <!– First-level item with submenu –> <a> <!– Destination URL –> </a> <ul> <!– Second-level menu container –> <li> <!– Second-level … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)