angular-material2

Angular 4: When and why is @Inject is used in constructor?

随声附和 提交于 2019-12-03 08:29:38
问题 Problem Statment I am learning Angular 4 and I have stumble upon a code where @Inject is being used in a constructor and I am not able to figure out why... Code and Source I am using Angular 4 Material Code Source: https://material.angular.io/components/dialog/overview In the code, they are injecting MAT_DIALOG_DATA constructor(public dialogRef: MatDialogRef<DialogOverviewExampleDialog>, @Inject(MAT_DIALOG_DATA) public data: any ) { } Can anyone please elaborate what does it mean and when

'mat-form-field' is not a known element - Angular 5 & Material2

白昼怎懂夜的黑 提交于 2019-12-03 08:05:57
问题 I'm trying to use <mat-form-field in an Angular project using Material2 but I've hit a wall. Getting the error message below. Uncaught Error: Template parse errors: 'mat-form-field' is not a known element: 1. If 'mat-form-field' is an Angular component, then verify that it is part of this module. 2. If 'mat-form-field' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<mat-form-field> <input matInput

day incorrect in angular material datepicker

倾然丶 夕夏残阳落幕 提交于 2019-12-03 07:08:17
问题 When I select a date I see the correct date in the field but, when I save, the datepicker send the day before the date I have selected ( 3 hours offset ) i am using angular reactive form and MatMomentDateModule for date picker . the problem is related to timezones but i just want to save the same date that the user enter to database . Code repreduced here : https://stackblitz.com/edit/angular-material-moment-adapter-example-kdk9nk?file=app%2Fapp.module.ts issue related to this on githup :

How can I make a theme-able Angular Material NPM module?

戏子无情 提交于 2019-12-03 06:59:36
问题 Is it possible to build an npm module that uses Angular Material and allows the components it defines to be styled by the consuming app's custom theme? As an example, say I create an npm module that includes a component with the following template: <button mat-raised-button color="accent">Click me!</button> Is it possible to import this component into two different apps, each of which defines a custom Angular Material theme, and have the button take on the "accent" color of the current app's

Angular 2 material nested md-list-item

痞子三分冷 提交于 2019-12-03 06:59:25
Using Angular 2 with material design, trying to get nested lists in sidenav I have code like <md-sidenav #sidenav class="sidenav" mode="over" opened> <md-nav-list> <md-card class="user-card"> <md-card-header> <div md-card-avatar class="user-avatar"></div> </md-card-header> </md-card> <md-divider></md-divider> <md-list-item *ngFor="let category of ategories"> <a md-line>{{ category.name }}</a> </md-list-item> </md-nav-list> </md-sidenav> which works fine and looks something like Now When i try to nest it, like <md-sidenav #sidenav class="sidenav" mode="over" opened> <md-nav-list> <md-card class

Is Angular 4 material responsive like bootstrap?

亡梦爱人 提交于 2019-12-03 04:40:50
问题 I am starting on a new project with Angular 4 and need to create responsive and pleasant user interface. bootstrap gives you responsiveness, but no material feel angular material provides that nice UI experience https://material.angular.io I know bootstrap and used it in previous AngularJS apps, but angular material is new to me. It seems easy to follow docs but i cannot find the responsiveness support. I don't want to mix them but have not been able to find that column responsiveness for

How to set the color of an icon in Angular Material?

时光毁灭记忆、已成空白 提交于 2019-12-03 04:15:32
I have this, which I would assume to work, but doesn't: <mat-icon color="white">home</mat-icon> Then, I also have: <button mat-raised-button color="accent" type="submit" [disabled]="!recipientForm.form.valid"> <mat-icon color="white">save</mat-icon>SAVE </button> This code snippet, for some reason, does work (shows the icon as white). How do I get the lone mat-icon to show up as white using the color attribute? (I can easily just add a white class, but I want to understand this) That's because the color input only accepts three attributes: "primary" , "accent" or "warn" . In other words, you

How to pass json data received from service to an array in component in angular material for angular 4

可紊 提交于 2019-12-03 04:07:30
I am new to Angular 4 and angular material and i am trying to add the angular material data table with http, pagination, sorting and filtering into my dashboard component, With hard-coded array i was able to achieve filter, sort and pagination. But i am not able to pass a json data from service into the array. Any help would be appreciated. Thanks in advance..!!! Please find my code below. test.json [{ "FirstName": "Jill", "LastName": "Smith", "Score": "disqualified" }, { "FirstName": "Eve", "LastName": "Jackson", "Score": "94" }, { "FirstName": "John", "LastName": "Doe", "Score": "80" }, {

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

大城市里の小女人 提交于 2019-12-03 02:40:29
问题 I'm trying to create a navigation bar using Angular material 2 that collapses in small screens like mobile devices and tablets. I was only able to find md-button but not md-menu-bar as was in Angular material. 回答1: 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

Angular Material 2 DataSource filter with nested object

旧街凉风 提交于 2019-12-03 02:40:01
I have angular 4 project with material 2, I want to filter the data in MatTable. DataSource filter is working fine when we filter data on field which are not nested. this.dataSource = new MatTableDataSource([ { orderNumber: 1, orderInfo: { type: 'ABC'}, date: '12/3/2012 9:42:39 AM'}, { orderNumber: 3, orderInfo: { type: 'Hello' }, date: '12/2/2018 9:42:39 AM'}, ]); Filter is working fine for orderNumber, date but not working properly with type field in orderInfo object. Sagar Kharche DataSource has filterPredicate() method that needs to override in our application as follows. Add this code in