How to make a responsive nav-bar using Angular material 2?

Here is what I used to build my responsive nav-bar using Angular2+ Material 2 and flex-layout in angular-cli app. (Please visit Install Angular Material and Angular CDK) 1) Install flex-layout npm install @angular/flex-layout -save 2) Include flex-layout in your app.module.ts import {FlexLayoutModule} from “@angular/flex-layout”; 3) Import imports: [ BrowserModule, FormsModule, HttpModule, RoutingModule, FlexLayoutModule, MyOwnCustomMaterialModule // … Read more

How to update angular material

You’ll want to use the npm update command. An example would look like this. npm update @angular/material @angular/cdk This will install the latest stable version. If you would like to target a specific version, you would have to specify it by adding the version to the end after an @ symbol. Additionally, you can check … Read more

Overriding Angular Material Size and Styling of md-dialog-container

From the official documentation: Styling overlay components Overlay-based components have a panelClass property (or similar) that can be used to target the overlay pane. You can override the default dialog container styles by adding a css class in your global styles.css. For example: .custom-dialog-container .mat-dialog-container { /* add your styles */ } After that, you’ll … Read more

custom filter in mat-table

I found the solution here. It’s necessary to rewrite filterPredicate, and just use it as usual, filterPredicate needs to return true when filter passes and false when it doesn’t export interface Element { name: string; position: number; weight: number; symbol: string; } dataSource = new MatTableDataSource(ELEMENT_DATA); /* configure filter */ this.dataSource.filterPredicate = (data: Element, filter: … Read more

Get Angular Material v2 slider’s value while sliding

As of v15 <mat-slider> <input (input)=”onInputChange($event)” /> </mat-slider> onInputChange(event: Event) { console.log(“This is emitted as the thumb slides”); console.log((event.target as HTMLInputElement).value); } Before v15 In your case, you would not listen to the (change) event but rather to the (input) event. Here is an example: <mat-slider (input)=”onInputChange($event)”></mat-slider> onInputChange(event: MatSliderChange) { console.log(“This is emitted as the … Read more

angular material 2 table header center alignment

Update for Angular Material 5.x.x, no need for ng-deep: mat-header-cell { display:flex; justify-content:flex-end; } DEMO md-header-cell get ‘translated’ to a container with class=”mat-sort-header-container”. Using that, you set its style with ng-deep. Use flexbox to center its content. Put the following in the components stylesheet: ::ng-deep .mat-sort-header-container { display:flex; justify-content:center; } DEMO

Template parse errors: ‘md-form-field’ is not a known element

UPDATE: Since 2.0.0-beta.12, md prefix has been removed in favor of mat prefix. See this CHANGELOG for details: All “md” prefixes have been removed. See the deprecation notice in the beta.11 notes for more information. After the update, <md-form-field> should be changed to <mat-form-field>. Also, MdFormFieldModule and MdInputModule should be changed to MatFormFieldModule and MatInputModule: … Read more